- Home /
How to force to jump eternally object?
How to force to jump eternally object (upwards - downwards, upwards - downwards, upwards - downwards)?
i'm not sure what you mean, do you want an object to move in one direction with a constant speed, or you want to make something move up, then move down and repeat? Elaborate please. En anglais preferably.
I am make GameObject move up, then move down and repeat forever. Need asynchrone. I create $$anonymous$$i game and me need if i click on my gameobject, this object looping jump.
I write this code: function FixedUpdate() { if(tmp4.collider.renderer) { if(tmp13==-1) tmp13=1; else tmp13=-1; for(i=1;i<4;i++) {
tmp4.transform.position=tmp4.transform.position+Vector3(0,tmp13*0.2*i,0); yield new WaitForSeconds (0.1);
} }
} but get error: FixedUpdate() can not be a coroutine.
Answer by Jeston 1 · Nov 10, 2010 at 08:45 PM
public float jumpSpeed = 8.0f; public float gravity = 20.0f; private bool grounded = false; private Vector3 moveDirection = Vector3.zero;
public void FixedUpdate() { if (grounded) { // We are on the ground so jump moveDirection.y = jumpSpeed; }
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
CharacterController controller = (CharacterController)GetComponent("CharacterController");
CollisionFlags flags = controller.Move(moveDirection * Time.deltaTime);
grounded = (flags & CollisionFlags.CollidedBelow) != 0;
}
This Script forces a character to jump eternally
Your answer

Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Help with my double jump script 1 Answer
how do I script this jump animation? 1 Answer
jump script 1 Answer
Addforce to create a gliding effect? 2 Answers