SPF_INTERPOLATE rubberband effect

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!)
User avatar
zvx333
Posts: 35
Joined: Mon Jan 24, 2022 2:51 pm

SPF_INTERPOLATE rubberband effect

Post by zvx333 »

Hi!

I'm creating a Recoil system for a mod I'm working on and I've noticed that the usage of the SPF_INTERPOLATE flag in A_SetPitch and A_SetAngle sometimes leads to a rubberband effect because of (supossedly) the way ZDoom handles mouse movement

Here is a video https://drive.google.com/file/d/1RZWbNV ... sp=sharing showing what I mean, the MP40 has this effect, and the SMG does not

Also, if you move the view to the left / right with the arrow keys instead of the mouse, it does not happen

These are the relevant code blocks, this first one generates the rubberband effect:

Code: Select all

ResumeFireFrame:
	MP40 A 0 A_JumpIfInventory("Zoomed",1,"Fire2")
	MP40 A 0 A_PlaySound("MP40/Fire", 1)
	MP40 A 0 A_PlaySound("FARSHT", 6)
	MP40 A 0 A_AlertMonsters
	MP40 A 0 ACS_NamedExecuteWithResult("SetRecoil", Random(20,30), Random(-20,20))
	MP40 B 1 BRIGHT A_FireBullets (3, 3, -1, 18, "WeakPuff", FBF_NORANDOM)
	TNT1 A 0 A_SetPitch(pitch-0.01*CallACS("Pitch"), SPF_INTERPOLATE)
	TNT1 A 0 A_SetAngle(angle-0.01*CallACS("Angle"), SPF_INTERPOLATE)
	MP40 A 0 A_ZoomFactor(0.998)
	MP40 D 1 
	TNT1 A 0 A_SetPitch(pitch-0.01*CallACS("Pitch"), SPF_INTERPOLATE)
	TNT1 A 0 A_SetAngle(angle-0.01*CallACS("Angle"), SPF_INTERPOLATE)
	MP40 A 0 A_ZoomFactor(1.0)
	MP40 A 0 A_FireCustomMissile("DecorativeTracer", random(-1,1), 0, 0, -12, 0, random(-1,1))
	MP40 E 1 A_FireCustomMissile("PistolCaseSpawn",-5,0,8,-4)
	TNT1 A 0 A_SetPitch(pitch+0.02*CallACS("Pitch"), SPF_INTERPOLATE)
	TNT1 A 0 A_SetAngle(angle+0.02*CallACS("Angle"), SPF_INTERPOLATE)
	MP40 A 1
	MP40 A 0 A_Refire
	Goto Ready3
While this other does not:

Code: Select all

ResumeFireFrame:
	MP40 A 0 A_JumpIfInventory("Zoomed",1,"Fire2")
	MP40 A 0 A_PlaySound("MP40/Fire", 1)
	MP40 A 0 A_PlaySound("FARSHT", 6)
	MP40 A 0 A_AlertMonsters
	MP40 A 0 ACS_NamedExecuteWithResult("SetRecoil", Random(20,30), Random(-20,20))
	MP40 B 1 BRIGHT A_FireBullets (3, 3, -1, 18, "WeakPuff", FBF_NORANDOM)
	MP40 A 0 A_SetPitch(pitch-0.01*CallACS("Pitch"), SPF_INTERPOLATE)
	MP40 A 0 A_SetAngle(angle-0.01*CallACS("Angle"), SPF_INTERPOLATE)
	MP40 A 0 A_ZoomFactor(0.998)
	MP40 D 1 
	MP40 A 0 A_SetPitch(pitch-0.01*CallACS("Pitch"), SPF_INTERPOLATE)
	MP40 A 0 A_SetAngle(angle-0.01*CallACS("Angle"), SPF_INTERPOLATE)
	MP40 A 0 A_ZoomFactor(1.0)
	MP40 A 0 A_FireCustomMissile("DecorativeTracer", random(-1,1), 0, 0, -12, 0, random(-1,1))
	MP40 E 1 A_FireCustomMissile("PistolCaseSpawn",-5,0,8,-4)
	MP40 A 0 A_SetPitch(pitch+0.01*CallACS("Pitch"), SPF_INTERPOLATE)
	MP40 A 0 A_SetAngle(angle+0.01*CallACS("Angle"), SPF_INTERPOLATE)
	MP40 A 1
	MP40 A 0 A_SetPitch(pitch+0.01*CallACS("Pitch"), SPF_INTERPOLATE)
	MP40 A 0 A_SetAngle(angle+0.01*CallACS("Angle"), SPF_INTERPOLATE)
	MP40 A 0 A_Refire
	Goto Ready3
Can somebody explain why this happens?

Thanks in advance

Best regards

Return to “Scripting”