- Home /
2d make sprite "bobble" on the Y whilst using velocity on x
Hi
But of a noon question but wondered if some could help me....
I am trying to make a bird move across the screen....currently using velocity. These birds are spawned. My current code looks like:
flyPrefab.rigidbody2D.velocity = new Vector2(flyPrefab.transform.localScale.x, 0f) (direction.x gameController.currentLevel.flySpeed);
Now what I would really like to do is have the bird move up and down a bit (so its harder to tap to kill) as it flies across. But I can't for he life of me work out how to do it.
I have tried what I thought would be a simple solution and made a animation of it move on the Y. However this does;t play well with the physics.
Any pointers would be very much appreciated.
Answer by KpjComp · Oct 16, 2014 at 12:14 PM
So the physics don't all get messed up, I think you want to use -> rigidbody.AddRelativeForce, this would be like giving the bird a push.