I have a script to rotate a platform:
using UnityEngine;
using System.Collections;
public class RotatingPlatform : MonoBehaviour
{
public float speed = 10f;
public float baseSpeed = 10f;
void Update () //stop time mechanic. When SHIFT is pressed, the object stops.
{
if(Input.GetKeyDown(KeyCode.LeftShift))
{
speed = 0f;
}
else if(Input.GetKeyUp(KeyCode.LeftShift))
{
speed = baseSpeed;
}
}
void FixedUpdate () //rotation
{
transform.Rotate(Vector3.up, speed * Time.deltaTime);
}
}
`
However, when the player collides with the platform, its rotation speed drastically slows. What is wrong with the code?
↧