Quantcast
Viewing all articles
Browse latest Browse all 2891

Member cannot be accessed with an instance reference; qualify it with a type name instead

I was in the middle of programming a block puzzle, when the block entered a trigger it's position was set to the triggers position and a door opened. So far everything worked, but I wanted to lock the block's position to the trigger so I tried to freeze the Rigidbody constraints but I got an error that said: "Member 'RigidbodyConstraints2D.FreezePositionX' cannot be accessed with an instance reference; qualify it with a type name instead" Here's the code: void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Box") { other.transform.position = transform.position; Door.SetActive(false); other.GetComponent().FreezePositionX = true; } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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