Question by
AllanMurison1 · Jul 10, 2018 at 03:59 PM ·
c#errorassetsgameobjects
The pickups aren't rotating on the spot, but around the screen. My player game object also isn't receiving input from my keyboard. What is going on?
My code: Player code: using UnityEngine; using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
private Rigidbody2D rb2d;
void Start()
{
rb2d = GetComponent<Rigidbody2D> ();
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector2 movement = new Vector2 (moveHorizontal, moveVertical);
rb2d.AddForce (movement * speed);
}
} 2d asset rotation code: using UnityEngine; using System.Collections;
public class Rotator : MonoBehaviour {
void Update ()
{
transform.Rotate (new Vector3 (0, 0, 45) * Time.deltaTime);
}
}
3d asset rotation code: using UnityEngine; using System.Collections;
public class Rotation : MonoBehaviour {
// Update is called once per frame
void Update () {
transform.Rotate (new Vector3 (15, 30, 45) * Time.deltaTime);
}
}
Comment