5 May, 2021 | By Magnus Frejd |
Instantiating projectiles & explosions
In this scenario:
A gameObject that is РІР‚СљLauncherРІР‚Сњ a projectile Prefab if the player presses the fire key. The Prefab includes a mesh, a Rigidbody, and a Collider, therefore it can travel through the fresh atmosphere and detect when a collision A collision takes place when the physics engine detects that the colliders of two GameObjects make contact or overlap, when a minumum of one features a rigidbody component and it is in movement. More information See in Glossary happens.
The projectile collides with something and instantiates an explosion Prefab. The explosion Prefab has a Particle System impact and a script that is applicable a potent force to surrounding GameObjects.
No matter how complex the projectile Prefab is in the same way as the Block Prefab above, you can instantiate the projectile in just one line of code. After instantiating the Prefab, you may alter any properties associated with the instantiated GameObject. For instance, the velocity can be set by you of this projectileРІР‚в„ўs Rigidbody.
In addition to being more straightforward to make use of, you are able to later modify the Prefab on without pressing the rule. Therefore if your projectile is a rocket, later on it to make it leave a cloud trail on you could add a Particle System to.