Quantcast
Channel: Questions in topic: "class instance"
Viewing all articles
Browse latest Browse all 131

create custom class

$
0
0
HI. I want create custom class in my script and define custom variables in this class. for do this I create another public class and defined my variables inside it. but when i play the game, it give me below error: **NullReferenceException: Object reference not set to an instance of an object** This is my script: using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class _Player : MonoBehaviour { Player player; // Use this for initialization void Start () { } // Update is called once per frame void Update () { player.x = transform.position.x; player.y = transform.position.y; } } public class Player { public float x; public float y; } Anyone know why unity give me this error? Thanks.

Viewing all articles
Browse latest Browse all 131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>