x


Character Movement and Jumping Script?

I have a script that allows for forwards, backwards, left and right movement but I can't jump. It's a third person game, so is there any script that allows jumping but also allows WASD/arrow keys movement?

more ▼

asked Oct 23, 2010 at 11:34 AM

brandon 1 gravatar image

brandon 1
0 8 8 12

can you tell me the script you are using for your project ?

Nov 02, 2012 at 12:51 AM TechedEd
(comments are locked)
10|3000 characters needed characters left

6 answers: sort voted first

This is a very basic code structure of how you could get your character to jump.

Add a public variable

public float JumpSpeed = 100.0f;

Then write a function for your jump

 void Jump()
{
    animation.Play("jump_pose");
    rigidbody.AddForce(Vector3.up *JumpSpeed);

}

Then in your update function just check if the player has pressed the jump button and if he has execute jump

 if (Input.GetButton(JumpButton)) 
     Jump();

PS - This would only work if your character is has a rigid body component attached to it and not a standard unity controller.

more ▼

answered Dec 08, 2010 at 10:25 AM

Sriram gravatar image

Sriram
243 25 24 30

But what if player holds long time jump button? Character would jump too high ^^ I think better would be "GetButtonDown" but it will be wrong too, when player fast push button several times.

Jun 07, 2013 at 07:44 AM St4rKiller070
(comments are locked)
10|3000 characters needed characters left

Please Walk Script in C#?

more ▼

answered Nov 19, 2012 at 08:57 PM

MrSaly gravatar image

MrSaly
0

(comments are locked)
10|3000 characters needed characters left

How use my animation with the walk script? in C#, please.

more ▼

answered Nov 20, 2012 at 09:53 PM

MrSaly gravatar image

MrSaly
0

(comments are locked)
10|3000 characters needed characters left

The default ThirdPerson-controller in Standard Assets does this.

more ▼

answered Oct 23, 2010 at 12:54 PM

StephanK gravatar image

StephanK
6.5k 116 103 148

(comments are locked)
10|3000 characters needed characters left
more ▼

answered Nov 13, 2010 at 01:30 PM

sonic220 gravatar image

sonic220
44 67 60 66

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4683
x2386
x1762
x222
x121

asked: Oct 23, 2010 at 11:34 AM

Seen: 45253 times

Last Updated: Jun 07, 2013 at 07:44 AM