- Home /
Need air control for 2D-Game
Hi, I make a 2D Game for my friend but no I have a problem that I don;t know! I don't really know about walk scripts and I wanne make a script so you can control the character in the air but i don't know how to make it can you help me? ( The CharacterController script is from Unity3d self)
here's the script:
var moveSpeed = 5.0;
var jumpSpeed = 8.0;
var gravity = 20.0;
private var moveDirection = Vector3.zero;
function FixedUpdate () {
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
moveDirection = Vector3(0, 0, Input.GetAxis("Horizontal"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= moveSpeed;
if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed;
}
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
@script RequireComponent(CharacterController)
how much program$$anonymous$$g experience do you have? Are you trying to edit a charactercontroller you wrote, or just starting out in Unity?
There are many considerations, but before you write a player script you need to decide what behaviour the player's character has. Is this a man on the ground game with a special ability, or a superman game?
@tom1103 please put comments HERE [add new comment]
really need to know about the project and what you're trying to do. "control the character in the air" is pretty vague. is the character an aircraft, a biped? Like I asked before, is this a biped that needs to be grounded and jump normally but then can also fly (unlimited by gravity). Like, what is going on? What is the character, what is it's list of behaviours?
Your answer
Follow this Question
Related Questions
OnCollisionEnter2D not triggering on parent 1 Answer
Move sprite from point A to point B 0 Answers
Moving with coroutines 2 Answers
Creating a 2D Movement Grid 0 Answers