Hey guys, this is my first question to ask the community so bear with me. I am creating a game where a pillar shows up on the battlefield and the player must interact with it before it respawns to another location. My question is; where do I start to just make the object show up in one spawn location, then appear in another? I appreciate any help given. I am not an experienced programmer but I do understand the basics of C#.
1 Answer
1Use the Objects transform position to set a new position for it.
transform.position = newLocationAsAVector3;
Have not tried this yet but have seen it in action. Will probably use this come time. Thank you.
– fbic333
Rather than respawn anything, just hide/show/move the object. Research: Transform.position Renderer.enabled Collider.enabled You may want to look at colliders, triggers, OnTriggerEnter() for interacting with the pillar.
– robertbuWow thanks guys. Those are great places for me to start. I appreciate the help.
– fbic333If the object is hidden will the players or AI run into it?
– fbic333If you turn off the collider, then neither the player or the AI will run into it. Note you could also disable it completely with GameObject.SetActive(). The only issue with disabling something completely is that many of the functions used to find game object will not find a disabled object.
– robertbu