Enemy shooting projectile animation

https://www.babylonjs-playground.com/#9WUJN#274

So far I have prototyped what I have in my mind in this playground.

The cube acts like the enemy and the sphere is the bullet that shoots from it. I thought that I could use the animation system and when the projectile reaches its max range/hits the player will be disposed from the scene.

My actual project below follows the same kind of logic with the sphere/bullet disappearing at the end

My problems right now :

1)The thing is after I dispose it, I want it to obviously repeat so it can shoot again but being disposed() makes it not possible since it doesn’t exist any more.

2)How can I make the bullet shoot from where the enemy/cube faces ? In my project’s screenshot that is more clear since the Skull always turns to face the player so I want the bullet to begin it’s trajectory from the skull’s front/face/nose. Think of like a turret for now that turns and shoots bullets to its facing direction constantly. I will implement the enemy detection later and when to shoot and whatnot.

The following examples will probably of some help to you:

Q

1 Like

So after being too stubborn and not using proper physics with cannon I caved in.

I made a prototype with my enemy turning and shooting bullets to my player but it seems I need to convert everything to account for the addition of physics in my project.

Will look into it more and provide more info.

Can’t really thank you enough for getting me in the right direction.

1 Like