- Home /
newbie 2d simple sprite rotation
Hello everyone! I need to rotate a wheel, by it's center origin, to make my 2d car move.
I didn't found anything..
I did this, but it only pushes the wheel, and is not good
rigidbody2D.velocity = new Vector2(move * 10, rigidbody2D.velocity.y);
Help me !
Also
float rot = Input.GetAxis("Horizontal") * 20;
transform.Rotate(0, 0, rot);
This will rotate the sprite, but it doesn't affect anything
maybe torque:
the car will only move if there is traction on wheel, search for 3d car propulsion questions, there are many, it's probably the same
Answer by HappyMoo · Jan 01, 2014 at 12:26 PM
There is no WheelCollider for 2D. It's worth a shot to try a normal Circle collider, but if that doesn't work, you'll have to roll your own WheelCollider2D and there's no CircleCast in Physics2D like SphereCast in Physics, which makes it harder.
So, let's try Circle-Colliders:
Import the Physic Materials package
Put "Rubber" on your CircleColliders and "Wood" on your floor.
float rot = Input.GetAxis("Horizontal") * speed; backTire.rigidbody2D.AddTorque(rot);
On every collider you have a material where you can assign your Physics$$anonymous$$aterials, but I just realized that you need Physics2D$$anonymous$$aterials... so you have to create them yourself:
In the Project, create "Physics2D $$anonymous$$aterial" and create one for your tire and one for your floor. Then give your tire material some bounciness, maybe 0.1 and test it out. Later you can play with the friction and bounciness to get the right feeling,
I creted with friction like 10, bounce 1, just to see if there any diference, i've added to my sprite, but nothing, same movement.
bounce only come into play if you fall/jump onto the material and friction... try 0 - it should be so slippery that you don't move anymore
Your answer
Follow this Question
Related Questions
2D Character grabing the wall 1 Answer
simple movement help 1 Answer
2D Movement Problems 2 Answers
Flipped objects Rotation issues 1 Answer
2D Animation does not start 1 Answer