- Home /
How to make a circle (player) rotate
I am making a game where the player is a circle which has 8 spikes or rectangles in it. I made a Movement script for this but whenever the player moves it just hovers instead of spinning. Although on a ramp it does start spinning but on flat ground it doesn't.
This is the movement script I used:
using UnityEngine;
public class Movement : MonoBehaviour {
public float MovementSpeed = 1; private void Start() {
}
private void Update() { var movement = Input.GetAxis("Horizontal"); transform.position += new Vector3(movement, 0, 0) Time.deltaTime MovementSpeed;
}
}
Answer by unity_DE3B9980ED8A9756A776 · Dec 12, 2021 at 08:37 PM
Try this with a rigidbody2d:
using UnityEngine;
public class obrot : MonoBehaviour
{
public float MovementSpeed = 1000f;
void Update()
{
var movement = Input.GetAxis("Horizontal");
GetComponent<Rigidbody2D>().angularVelocity = -(MovementSpeed*movement);
}
}
Your answer
Follow this Question
Related Questions
Move player in circle around center 0 Answers
Making player move based on direction they are facing 1 Answer
Player Going through colliders 1 Answer
Orbit player around center point 1 Answer