Thrust player in the direction an actor is facing?

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
StankyTree
Posts: 13
Joined: Sun Nov 03, 2019 8:17 am
Graphics Processor: nVidia (Modern GZDoom)

Thrust player in the direction an actor is facing?

Post by StankyTree »

Code: Select all

actor SlantedSpringboard 3501
{
//$Category PlatformingTools
//$Title SlantedSpringboard
//$Angled
//$Sprite BBOUA0
	Radius 20
	Height 5
	Scale 1
	+NoGravity
	States
	{
	Spawn:
	  BBOU A 0
	  TNT1 A 0 A_JumpIf(Args[0] == 0, "blue")
	  TNT1 A 0 A_JumpIf(Args[0] == 1, "yellow")
	  TNT1 A 0 A_JumpIf(Args[0] == 2, "red")
	Blue:
	  BBOU A 1 A_CheckProximity("bluebounce","playerpawn",30,1,CPXF_ANCESTOR)
	  loop
	BlueBounce:
	  BBOU A 1 A_ChangeVelocity(15,0,18,CVF_REPLACE|CVF_RELATIVE,AAPTR_PLAYER1)
	  BBOU A 0 A_SetAngle(angle,SPF_INTERPOLATE,AAPTR_PLAYER1)
	  goto Blue
	Yellow:
	  YBOU A 1 A_CheckProximity("yellowbounce","playerpawn",30,1,CPXF_ANCESTOR)
	  loop
	YellowBounce:
	  BBOU A 1 A_ChangeVelocity(23,0,28,CVF_REPLACE|CVF_RELATIVE,AAPTR_PLAYER1)
	  BBOU A 0 A_SetAngle(angle,SPF_INTERPOLATE,AAPTR_PLAYER1)
	  goto Yellow
	Red:
	  RBOU A 1 A_CheckProximity("redbounce","playerpawn",30,1,CPXF_ANCESTOR)
	  loop
	RedBounce:
	  RBOU A 1 A_ChangeVelocity(30,0,35,CVF_REPLACE|CVF_RELATIVE,AAPTR_PLAYER1)
	  RBOU A 0 A_SetAngle(angle,SPF_INTERPOLATE,AAPTR_PLAYER1)
	  goto Red
	}
}
So far I technically have it working, only problem is that it only works if I snap the players movement to match the actor, since A_ChangeVelocity is relative and I can't use the springboard's angle for it as far as I know.

I tried using ThrustThing, but it can't use pointers to effect the player, is there any way for me to do this? I assume there is, i'm just kinda stumped.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Thrust player in the direction an actor is facing?

Post by Jarewill »

You could replace the CVF_RELATIVE flag with some trigonometry functions, like so:
A_ChangeVelocity(15*cos(angle),15*sin(angle),18,CVF_REPLACE,AAPTR_PLAYER1)
StankyTree
Posts: 13
Joined: Sun Nov 03, 2019 8:17 am
Graphics Processor: nVidia (Modern GZDoom)

Re: Thrust player in the direction an actor is facing?

Post by StankyTree »

I've figured it out quite a while ago, I simply assigned a tag to the player and made it thrust them based on the angle of the actor.
Post Reply

Return to “Scripting”