i new unity , trying learn basics, learn physics @ school(ten grade).
what have done far - added ball project , used gravity on rigidbody
.
i want make ball jump on air when there touch input, example - flappy bird.
my script basic:
void update() { if (input.touchcount == 1) { getcomponent<rigidbody>().addforce(new vector2(0, 10), forcemode.impulse); } }
with script, ball falling(gravity) , when touch script, y coordinate changes happens sudden (no animation) , changes ~1 , continue falling(i can't keep ball on screen) , can make jump once, if press multiple times jump once, can see here: https://vid.me/arfk
thank helping.
i have created same scene in unity3d editor , played little same setup have. , yes had similar problems adding force on update , (but less) on fixedupdate. adding force on lateupdate seems work okay.
here code:
public rigidbody2d rb2dball; void lateupdate() { if(input.getkeyup(keycode.space)) { rb2dball.addforce (vector2.up * 10f, forcemode2d.impulse); } }
and turned on interpolation:
i cant why physics bahaves this, bug in unity3d 5.x since on fixedupdate should work fine.
Comments
Post a Comment