0

Weapon Projectile stay in place

Tanguy Despat 2 weeks ago in Shooter updated 2 weeks ago 2

Hi guys

I try to use the shooter module for the first time but I have an issue, I try to shoot with an ammo which is set to a projectile type but the prefab just stay in place at the muzzle position when I shoot.

The muzzle component is placed inside the gun prefab on an empty child

And this is the bullet prefab

Please guys help me to understand why the projectile is not moving at all

Cheers

Unity version:
2019.4.0f1
Game Creator version:
1.1.9

hi there!

It's not moving because the bullet prefab needs Physics and Impulse to move forward.

Try this:

- In your bullet prefab add the component RigidBody.

- Also in your bullet prefab add a trigger of type On Enable. After that add an Action called Physics to that trigger. In this action you have to inform a value to the Z axis that will work as the velocity of the bullet. For test purposes put something like 5 or 10, just to be able to see if it works.

- After that, if you wish to the bullet disappear after collide with anything, add another trigger to the bullet prefab of type On Collision enter. Add the action Destroy and in the Game Object field you drag the bullet prefab itself.

Try test it in the game mode. If all works out, you'll be able to see the bullet flying forwards at the speed of 10 in the Z axis. You can change this speed in the Physics action as you like.

You can also try tweaking the RigidBody configurations as gravity if you want the bullet to have some "weight" after shooting, whats gives a bit of realistic behavior for projectiles.

Hope it helps.

Amazing answer, I'm gonna try it as soon as I can and will come back here to tell you if it works.

Cheers