- Home /
continous movement for rigidbody2d using addforce with buttons
public void Moveright(){ RB2D.AddForce (Vector3.right*moveSpeed); moveVelocity = moveSpeed; }
this is the code i used to let the object move but the object only moves little by little and i have to continuously press the button....how do i make it move with just pressing the button...
i used onpointerdown in the event trigger but even if i hold the button...the character moves little by little..
Answer by shriya · Jul 29, 2015 at 11:44 AM
Hi,
Check this link. http://docs.unity3d.com/ScriptReference/ForceMode.html
Answer by 13yearoldceo · Aug 09, 2015 at 02:48 PM
try using rigidbody2d.velocity instead because addforce is usually meant for a single push so it seems like that it keeps pushing you each frame velocity is more of continuous movement; hopes this helps.
Your answer
Follow this Question
Related Questions
How to make an object invisible before it is triggered to show? 2 Answers
Moving Player Left/Right with Buttons 2 Answers
How do I make a script only affect one gameobject 2D 3 Answers
How do I fix these two errors in my Number Wizard Game? 2 Answers
Can not click buttons in the animator (2d),Can not click buttons in the animator 0 Answers