This shows you the differences between two versions of the page.
pjv:laboratoare:en:03 [2019/10/23 15:18] alexandru.gradinaru |
pjv:laboratoare:en:03 [2019/10/23 15:19] (current) alexandru.gradinaru [2D animations in Unity] |
||
---|---|---|---|
Line 113: | Line 113: | ||
For shooting animation, a status is generally used to update the player's animation, and the projectile is generated as follows (recommended): | For shooting animation, a status is generally used to update the player's animation, and the projectile is generated as follows (recommended): | ||
- | * A script is added to the weapon (which is on the scene) that manages the projectile generation and direction | + | * A script is added to the weapon (which is on the scene) that manages the projectile generation and direction |
- | * Starting from the location of the weapon, a projectile (using the Instantiate function, already studied) is instantiated (prefab as a rule, it must not already exist on the scene, using the position of the weapon). The projectile has attached a script containing details of speed, damage, etc. | + | * Starting from the location of the weapon, a projectile (using the Instantiate function, already studied) is instantiated (prefab as a rule, it must not already exist on the scene, using the position of the weapon). The projectile has attached a script containing details of speed, damage, etc. |
- | * The projectile has a continuous translational motion in one direction, until it reaches a limit or collider when it triggers | + | * The projectile has a continuous translational motion in one direction, until it reaches a limit or collider when it triggers |
=== Animations and scene instancing ==== | === Animations and scene instancing ==== | ||
Line 138: | Line 138: | ||
</code> | </code> | ||
- | === Colision === | + | === Collision === |
For collision detection a collider2D can be used. For easy interaction, a Trigger can be generated at the collision event by ticking the ''Trigger'' box in the component. After that you can retrieve the event and the object with which the collision is made. | For collision detection a collider2D can be used. For easy interaction, a Trigger can be generated at the collision event by ticking the ''Trigger'' box in the component. After that you can retrieve the event and the object with which the collision is made. |