How to change player's speed ?

Avatar
gallardo
85 Posts
Posted Sep 13, 2013
Hi,
I'm searching for a way to counter the speed of the player, like when he's falling.
I know there's a critical speed threshold (hardcoded btw ??), but I'd like to know if I can change it at runtime via console command in some way.

Example: I teleport the player after a high fall and so when it reappears he obviously maintain his previous speed. Ho to change it?

What I tried is using speedmod and it can stop it also, but when re-enable, the speed returns the one before.

another solution could be using a trigger_vphys, but seems cheap.

Any idea?
Thanks!

Advertisement
Registered users don’t see ads! Register now!
Avatar
AntiVector
102 Posts
Posted Sep 13, 2013
Replied 2 hours later

gallardo wrote:
Hi,
I'm searching for a way to counter the speed of the player, like when he's falling.
I know there's a critical speed threshold (hardcoded btw ??), but I'd like to know if I can change it at runtime via console command in some way.

Example: I teleport the player after a high fall and so when it reappears he obviously maintain his previous speed. Ho to change it?

What I tried is using speedmod and it can stop it also, but when re-enable, the speed returns the one before.

another solution could be using a trigger_vphys, but seems cheap.

Any idea?
Thanks!

I'm not really sure what you mean here. Are you looking to slow the player's falling speed? Because a player_speedmod that's on all the time will do that. If you want to reduce the player's max speed throughout the map, then by all means create omnipresent trigger_vphyses that reduce the player's max velocity.

Avatar
gallardo
85 Posts
Posted Sep 14, 2013
Replied 10 hours later
yes, a player_speedmod does that until active, but once you disable it, the speed of the player returns the same as before.
example: player is falling at 3000 "speed", I activate speedmod 0 to completely stop the player in mid-air, I deactivate speedmod (value=1), the player return to fall at speed = 3000.

I can use a vphys but I wanted toknow if there's a more refined and practical solution before.

Avatar
FelixGriffin
2,680 Posts
Posted Sep 14, 2013
Replied 3 hours later
!player RunScriptCode self.SetVelocity(Vector(0,0,0)); will kill the player's velocity instantly, although if you don't use anything else they'll immediately start falling again.
Avatar
AntiVector
102 Posts
Posted Sep 14, 2013
Replied 3 hours later
Aaah, killing the player's speed in mid-air is what you want. If you don't want to mess about with scripts, then create a thin trigger_catapult where you want the player to stop. Set the Player Speed and Physics Object Speed to 1. Then, to prevent multiple stops, add two outputs to the trigger:

OnCatapulted [your trigger_catapult name] Disable
OnEndTouch [your trigger_catapult name] Enable

The nice part about this is that it also takes care of physics objects.

Avatar
TeamSpen210
608 Posts
Posted Sep 14, 2013
Replied 2 hours later
Don't set it to zero. I was actually experimenting with that, an it crashes the game as soon as the player touches the ground.
Avatar
AntiVector
102 Posts
Posted Sep 14, 2013
Replied 2 hours later

TeamSpen210 wrote:
Don't set it to zero. I was actually experimenting with that, an it crashes the game as soon as the player touches the ground.

???

I repeated the experiment, I never encountered this problem. In any case, just set it to 1 then.

Advertisement
Registered users don’t see ads! Register now!
Avatar
gallardo
85 Posts
Posted Sep 22, 2013
Replied 7 days later
I went for a trigger_vphys (same as trigger_catapult). it's ok even if a dirty solution.
vscript is fine, but I don't know yet if the mod will run of portal2 or previous engine without script support.

thanks!