- Home /
monotone movement with rigidbody.addforce
hi guys , here is a very .... problem ,would anybody help me plz.... i wanna shoot a bullet in a curve path with rigidbody.addforce but when i instantiate it and apply addforce on it , its got a rapid movement at the begining and slower movement at the falling part , this is the code ive written
function OnMouseDown ()
{
var DirectionVec : Vector2 = Vector2(1,1);
Clone =Instantiate ( Bullet , transform.position , transform.rotation);
Clone.rigidbody.AddForce (DirectionVec * Time.deltaTime * 30000 ) ;
}
ofcourse i turn use gravity on ... and also when i use addforce in several frames such as in update function ive got problem with the curve path , mean that the bullet doesnt move correctly in the curve... so i explain my problem again .maybe the answer helped other too i have a bullet that wanna move it in a arc path ,my solution is that apply addforcr in just one frame and turn the gravity on , so that after reaching the bullet to apex point it falls with gravity, but the frist half of movement is too quick and the second is slow ,or they havent same speed......... so would anybody..... thanx again and again thanx
Answer by Narv · Aug 13, 2013 at 11:12 AM
It looks like you are trying to change the way the force is applied, correct? AddForce has a 2nd optional parameter you can use
http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForce.html
It takes a ForceMode. You can control how the force is applied (at once, or continuous) and with or without regard to mass:
http://docs.unity3d.com/Documentation/ScriptReference/ForceMode.html
im checking it , but seems that theres an untold problem, i wanna reach from a to b , whats my best solution,shuld i apply force in just on frame and turn the gravity on ? or.....if i want to make it more simple , its something like the birds movement in the angrybird...for example how the birds move slowly in their curve path and again thanx
im completely confused now.... without gravity we cant have a curve movement and with gravity and in just one frame applying addforce , we have faster movement till apex point and slower , the remaining path
i solved the first part of problem , i had a mistake in setting the camera orthographic size , it was set on 3 , now ive changed this parameter to 100 , and now i can have the full motion slow and , but the second part of problem is the movement isnt so gentle ,and its kindly frame by frame !!!