I’ve discovered an interesting effect. If you add a rigidbody to your obstacles, check “use gravity” and give it a drag value of 1000 (haven’t tested higher or lower) you get this floating debris effect if you bump into them with your rocket.
This could be really cool if you gave the rocket ship a health value, rather than one impact = game over, then have a level strewn with this debris (looks a little like zero gravity alien architecture with the way you have laid it out!).
You could consider dropping a script onto these to trigger the rotation, speed, direction and include a bit of a random range, thus they could be spinning prior to collision (asteroids perhaps?), and all be different - and different each time you play potentially.
It would be fun to find out, how to just add a bit of random force and let the physics do the rest…hmmm…
I like that idea! By now my levels look more like the inside of a bubbly alien But I keep this in the back of my head until I get to a point in the course where I might learn how to do this.
You could perhaps use the Random.Range
method to produce values for the X, Y and Z components of a new Vector3, and then pass that into the Rigidbody.AddForce
method.
The Rigidbody would be that of one of your objects in the scene which you want to manipulate, to which you add a script using the above.
Be aware of the inclusive/exclusive differences using Random.Range
with floats and ints.
Hope this helps.
See also;
- Unity - Scripting API : Random.Range
- Unity - Scripting API : Rigidbody.AddForce