problems when firing projectiles and moving

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
dremor8484
Posts: 21
Joined: Sun Apr 30, 2023 8:44 pm

problems when firing projectiles and moving

Post by dremor8484 »

when i fire a weapon like plasmagun, all projectiles exit from the weapon if i do not move
but if i strafe right whilw shooting, i can now see projectiles exiting from thin air on my left

is there a way to make all projectiles being aligned, even while i am moving and shooting ?
snakebyte
Posts: 19
Joined: Sat Apr 22, 2023 10:47 am
Preferred Pronouns: He/Him

Re: problems when firing projectiles and moving

Post by snakebyte »

I guess this is the normal behaviour. There is no like inertia for every projectile created by a moving actor.

You could maybe add inertia if you get the vector speed of the actor firing the projectile and add it to the vector speed of the projectile. But I wonder how weird it could be, because it could become impossible to aim at a target if you are moving.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: problems when firing projectiles and moving

Post by Jarewill »

Projectiles are spawned at the player's center before they start moving, which is why they appear to spawn from nothing when strafing.
To fix this you could use the function from this topic and add a little bit of X offset to make the projectiles spawn in front of the player rather than at the center.

If you don't want to do that, you can always add the player's velocity to the projectile as snakebyte mentioned:

Code: Select all

		PLSG A 3{
			let proj = A_FireProjectile("PlasmaBall");
			proj.vel += self.vel;
		}
However this will make aiming problematic.
Post Reply

Return to “Scripting”