Instantiate — Unity
In the previous article, I covered Classes in Unity.
This article will dive into the Instantiate method.
What is Instantiation in Unity?
Get Zac Bogner’s stories in your inbox
Join Medium for free to get updates from this writer.
Instantiation is a method to where a new object can be created or spawned within a given location, direction, and rotation.
Here the object being instantiated is in the wrong axis rotation.
To envision the transform coordinates in Unity, here’s an example of how each coordinate responds within its relative direction.
- X is the Left or Right Axis.
- Y is the Up and Down Axis.
- Z is the Forward and Backward Axis.
An example of a new game object within the scene to showcase the Transform properties for the directional movement, X, Y and Z.
For the Instantiate code, I’ll use a rocket instance, that will be for the instantiate method. This will return the rocket prefab Rigidbody (since Rigidbodies take in Physics parameters). A position and rotation coordinate, and a force to send the projectile out in a direction and force amount.
The current projectile position is pointing in the Z axis, which this will send the rocket projectile forward, hence the forward position in code.
The forward position for the rocket projectile in action.
I want the rocket projectile to be created along the forward axis (literally… within the correct coordinate (this being the Y axis)).
In code, I’ll change the forward forward direction (z) for the spawn position to the up direction (y) to have a proper spawn mechanism.
And now the correct instantiate object is applied within the proper axis (y).
And that’s all for Instantiation in Unity.
Stay tuned for more.
Thanks,
Zac B.









