- Home /
rotation and friction not working as expected
as you can see in this video: https://youtu.be/shF56eqDxHc the objects rotating were expected to push themselves forward like cars of a wheel do, but unfortunately this doesn't appear to be the case. to rotate the objects i'm using theese lines of code: using System.Collections; using System.Collections.Generic; using UnityEngine;
public class rotaet : MonoBehaviour
{ private float rotZ;
void Update()
{
rotZ += Time.deltaTime * -500;
if (Input.GetKeyDown("f"))
{
}
transform.rotation = Quaternion.Euler(0, 0, rotZ);
}
}
are there any easy ways for me to fix it?
Does the object have a rigidbody? It seems to just be floating in the air.
Answer by logicandchaos · Jan 12, 2021 at 11:47 AM
You need to use rigidbodies and angularVelocity for that. transform.rotation, transform.Translate, all the transform methods have no physics involved, you have to use rigidbody methods and attricbutes.
Your answer

Follow this Question
Related Questions
How do 2 Physics Material 2D Interact with Each other? 2 Answers
rotation speed cap in 2D 0 Answers
Remove Drag/Friction 1 Answer
2D Animation does not start 1 Answer
2D platformer wall troubles 0 Answers