[CODE] Smooth stair/camera movement

Post your example zscripts/ACS scripts/etc here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
Post Reply
Turret49
Posts: 92
Joined: Sat Aug 29, 2015 1:40 pm

[CODE] Smooth stair/camera movement

Post by Turret49 »

(aka No More Slipping)

-------
Update 4/7/16
- Now smooths if the player climbs up a step while in midair.
- Added basic elevation detection using a dummy actor, camera will now account for lift movement instead of squashing/stretching.
- (lift detection is buggy when you stand on the edge, and actor platforms aren't detected at all)

-------

A bit tired of losing control and slipping around whenever Doomguy comes across even the slightest gradation in the ground, I made this script which attempts to keep the player's feet firmly on the floor and let them be able to fully control their movement. This script also takes control over the player's ViewHeight, giving a smoother stair-travelling experience.

Note that you will still fall off stairs if they are too steep to run down. (Also I am not that experienced at ACS so sorry for any newbie-isms)

Credits to Epic MegaGames and Digital Extremes for the smooth camera code, also KeksDose for a tiny bit of code borrowed from Trailblazer.

Download link: https://www.mediafire.com/?o7o73w19j987lic

I also made an example map to help show the difference the script makes, don't run it with the .pk3 though, as an altered version of the script is already embedded within the wad.
You can get the map here: https://www.mediafire.com/?cyrrhg7zp21dd04 (uses outdated version of script!)

Image
Last edited by Turret49 on Mon Jul 04, 2016 6:37 am, edited 4 times in total.
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: [CODE] Smooth stair/camera movement

Post by Gutawer »

Thanks for this, seems to work pretty well. Just wondering, does it have any effect on slopes?
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [CODE] Smooth stair/camera movement

Post by Nash »

[commenting to check this out in future]
Turret49
Posts: 92
Joined: Sat Aug 29, 2015 1:40 pm

Re: [CODE] Smooth stair/camera movement

Post by Turret49 »

Gutawer wrote:Thanks for this, seems to work pretty well. Just wondering, does it have any effect on slopes?
From what I've looked at the player seems to grip slopes a bit more, but it doesn't appear to have any affect on actual control, sadly.

Updated the OP with a new version after finding some issues with the first one. the new lift detection is really buggy but I'm not sure of a better way to do it. In GZdoom there's even a bug at the start of a map (DUMP 2 MAP28) That is entirely random (somehow arbitrarily based on the size of the script, including commented out text) where the dummy actor reverses its Z height (and FloorZ) information for a couple seconds and I can't figure out how to stop it from happening. Doesn't happen in ZDoom, either.
User avatar
BROS_ETT_311
Posts: 218
Joined: Fri Nov 03, 2017 6:05 pm

Re: [CODE] Smooth stair/camera movement

Post by BROS_ETT_311 »

Terribly sorry to necropost this, but I swear it's not a useless bump. It seems this code might be a bit broken on newer GZDoom versions, at least 4.0 and up. Currently, the player view height defaults to what looks to be the floor, however...I believe I have a fix! This could be completely wrong, but it seems to do the trick. I know there are ways to do this in zscript (i.e. viewtopic.php?f=105&t=63331), but I figure this ACS still has some value amongst ZDoom 2.8.1 and Zandronum users.

Code: Select all

If( bFalling == 0 && !bJustLanded || LocationZ > OldLocationZ + OldVelZ)
		{
			bJustLanded = false;
			EyeHeight = FixedMul((EyeHeight - LocationZ + (OldLocationZ + LiftMom)), (1.0 - smooth)) + FixedMul(BaseEyeHeight, smooth);
			bound = FixedMul(0.25, CollisionHeight);
			if (EyeHeight < bound)
				{EyeHeight = bound;}
			else
			{
				bound = CollisionHeight;
				if ( EyeHeight > bound )
					{EyeHeight = bound;}
			}
			//SetActorProperty(0,APROP_ViewHeight,EyeHeight);  //<------------ original code
			SetActorProperty(TempTID,APROP_ViewHeight,EyeHeight);  //<------------ FIX
		}
		
		else
		{
			smooth = 0.35;
			EyeHeight = FixedMul(EyeHeight, (1.0 - smooth)) + FixedMul(BaseEyeHeight, smooth);
			bJustLanded = false;
			//SetActorProperty(0,APROP_ViewHeight,EyeHeight);  //<------------ original code
			SetActorProperty(TempTID,APROP_ViewHeight,EyeHeight);  //<------------ FIX
		}
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [CODE] Smooth stair/camera movement

Post by Nash »

I should look into porting this into ZScript at some point.
User avatar
BROS_ETT_311
Posts: 218
Joined: Fri Nov 03, 2017 6:05 pm

Re: [CODE] Smooth stair/camera movement

Post by BROS_ETT_311 »

Nash wrote:I should look into porting this into ZScript at some point.
Oh hell yeah! I mean...once your done with ALL of your other projects, of course lol.
Post Reply

Return to “Script Library”