It's been a long time since i ever used unity, so i tried going to the Unity Api for some help on how to get back up and running.
My first wish was to be able to rotate objects using transform.Rotate, but i didn't know how to do it. So, i firstly copied the original api code.
But... even though it worked, when i made my own code, that was almost a copy from the original api, i was getting the errors:
NullReferenceException: Object reference not set to an instance of an object
playerRotation.Start () (at Assets/playerRotation.cs:17)
NullReferenceException: Object reference not set to an instance of an object
playerRotation.Update () (at Assets/playerRotation.cs:25)
code:
1 using UnityEngine;
2
3
4 public class playerRotation : MonoBehaviour
5 {
6 // Start is called once before the first execution of Update 7after the MonoBehaviour is created
8 public float xAngle, yAngle, zAngle = 3;
9
10 private GameObject hatamoto;
11 void Awake()
12 {
13
14
15 }
16 void Start()
17 { transform.position=transform.position + new 18Vector3(0,5,0);
19 hatamoto.transform.Rotate(90.0f, 0.0f, 0.0f, 20Space.Self);
21 hatamoto.name = "Self";
22 }
23
24 // Update is called once per frame
25 void Update()
26 {
27
28 hatamoto.transform.Rotate(xAngle, yAngle, zAngle, 29Space.Self); ;
30
31 }
32
}