- Home /
Rotating platform does not rotate character
I want to make this platform, but when it comes to character, it doesn't turn with the platform.
Answer by DevManuel · Feb 18, 2021 at 12:08 PM
Can you please give us a little bit more details?! Maybe you show us your which you have until now.
My idea would be setting the player as a child of the current platform. When the platform is turning the player should turning, too. Then when the player leaves this platform, simply remove the player from it and add the character to another platform. I think thats not the best solution, but you can give it a try.
[SerializeField] private float rotSpeed;
private Rigidbody rb;
void Update()
{
transform.Rotate(0, 0, Time.deltaTime * rotSpeed, Space.Self);
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("Player"))
{
rb = collision.gameObject.GetComponent<Rigidbody>();
InvokeRepeating(nameof(LeftAddForce), 0, 0.01f);
}
}
private void OnCollisionExit(Collision collision)
{
if (collision.gameObject.CompareTag("Player"))
{
CancelInvoke(nameof(LeftAddForce));
}
}
private void LeftAddForce()
{
rb.AddForce(Vector3.left * 100, ForceMode.Acceleration);
}
I think this is how I solved my problem, but I have contradictions about its performance.
Your answer

Follow this Question
Related Questions
Camera rotation around player while following. 6 Answers
Problem with imported object rotation 0 Answers
i want an object rotate 45 degrees more than an other one 1 Answer
How do i start an animation from the current rotation ? 0 Answers
How can I make my airplane rotate by my cursor position? 1 Answer