Object destruction in zero gravity game (space shooter)
Hi there, can somebody help me out here? I'm working on a smal space shooter, and I want to be able to destroy Asteriods when hitting them with the laser. I have a very basic skript to swap the objects and that work fine. The only problem is that the destroyedVersion needs a Rigidbody and it falling down now. Of course I've unchecked "Use Gravity", but it still falls out of my gameworld. Any ideas?
Answer by unity_21erushbrook · Aug 16, 2018 at 08:42 PM
Just assign the hit asteroid to a hitAstroid GameObject variable. You can call Destroy(hitAstroid); when you want to destroy the asteroid.
Hope this works as you want it to.
Answer by KOCGI · Aug 16, 2018 at 08:56 PM
asteriodHit = GameObject.FindWithTag("Asteroid");
Instantiate(destroyedVersion, transform.position, transform.rotation);
Destroy(asteriodHit);
Still it adds gravity, and the "destroyedVersion" falls down. Is there any other way around it? Or am I doing something wrong?
Answer by Cobra_03 · Aug 17, 2018 at 09:47 PM
I'm not sure why you want to swap objects rather than just destroying them in the code for on trigger enter but that being said, consider going to the rigidbody constraints for the asteroids and freeze the y position.
Your answer
Follow this Question
Related Questions
how to show destruction in unity??? 0 Answers
Super simple rigid body destruction, how? 1 Answer
NES Battle City destroyable walls 0 Answers
Instantiate many objects in a shape of another object (a mesh) 1 Answer
Unity Stop Destroy(gameObject) destroyinng objects instantiated by this script 0 Answers