Hello everyone. I’m working on a platformer with a running cat that has a gun on top, a gun that shots projectiles. The gun turns in such a way that it aims at the cursor. Since the cat was running continuously, when I tried to shot, the projectiles were apparently going backwards relative to the cat. I found a solution that involved getting the velocity of the character using the node " Get Velocity" , then adding it to the velocity of the projectile after it spawned. That worked well, however when the character got on a moving platform, the platform’s velocity was not added to the projectile.
As explained here: How do I account for player motion when firing a projectile? - #4 by Evilraptor
The character’s velocity is internal so moving platforms don’t affect it. In that case, I decided to calculate it externally and built this graph :
While running in a straight line, the printed velocity value seems the same as the “Get Velocity” solution, and it makes the projectile go straight as expected, but only if the character is not going up and down. I guess that I need to calculate velocity in such a way that it takes into account multiple axis/vectors so it gives similar results as the “Get Velocity” node.
I also tested replacing the forward vector with up vector and print the values, and fortunately they do change while on the up/down platform. Still, the projectile trajectory was not compensated, maybe because the lack of the X component.
So…,how to calculate velocity in such away that projectile’s trajectory is compensated regardless if the character is on moving platforms or not ?