Hi everyone, I’m trying to make a javascript that move a ball by using aceleration when I push a key(not for mobile devices). Could anyone tell me how to do it or just give me the clue to think it by myself?
Thanks
Rigidbody.addforce should do the job just fine.
Check for key input:
if(input.getkey(keycode.uparrow)){} etc.
Then add the appropriate force to the transform. Vecter3.up etc.
The developers of Unity could give you a clue, in fact they did : it’s called the Scripting Reference. Have you read it?
Here are the first places you need to look:
Thanks both, and sorry for being so noob, yes i knew the scripting guide but you know, you have to know what to ask :S
Tanks again
As mentioned above, you can use RigidBody.AddForce(). Typically the scripts I see on this list use AddForce() just once to (to shoot a projectile for example) and the object is up to speed. But your question asked about acceleration. If you want to cause something to speed up over time, you have to add a bit of force over a number of frames, rather than one explosive force. As an alternative, take a look at the Constant Force component (Component/Physics/Constant Force). In addition, if you are modeling anything that has a real world enlivenment, you will get best results from the physics engine if the size and mass of your object match the real world objects.