How can I make a ball jump if you press the space bar.
(The ball has a script very much like the ball rolling script in the Marble project).
How can I make a ball jump if you press the space bar.
(The ball has a script very much like the ball rolling script in the Marble project).
Hi Sam, you can find what you are looking for here:
http://unity3d.com/Documentation/ScriptReference/Rigidbody-velocity.html
There is also a lot useful info in the tutorials:
http://unity3d.com/Documentation/Manual/Tutorials.html
go ahead and check it out… you won’t be sorry!
i haven’t looked at the marble project but you could also take a look at the fpswalker script. set the jump button in the input manager to spacebar (think that’s the default).
snippet…
if (Input.GetButton ("Jump"))
{
moveDirection.y = jumpSpeed;
}
That work a lot better than my useless one!
But you can jump in the air.
Hi Sam… little by little!
As you progress and continue on your project, you’ll find that making games is all about those little cases. Sadly, there is no “duplicate reality” script (not yet heh!)
In the meantime, I recommend that you take a look at the tutorials (via the link above) and work through them. They are very easy to follow and I’m confident doing so will help you in many wonderful ways.
Once you do, to address your comment, you’ll want to check if your object is on the ground, and if it is, only then check for button input (via the jump button). The FPS script that Pete mentions does this.
OK! Thanks!
(I’ve looked at tuts).
ah yes, sorry! didn’t mean to imply that would work out of the box. just pointing it out… i hear duplicate reality™ is slated for 2.0 (oh don’t go quoting me on that!)
ooooh juicy!!
::Casemon:: slides over to the Gossip forum for some “a little bird told me” posting…
note re: “little bird” i’m not assuming anything about your stature Pete, it’s just that calling you “big bird” would have been too weird…
sam, forgot to mention, iirc the fps script is set up to use the character controller. i believe isgrounded is specific to the character controller. you might need to cast a ray down to get the distance (or something) if you aren’t using the cc. double check for yourself though - i’d have to look and i didn’t. anyway… good luck with it!