Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help SetPlayerCrouching(true); not working while LShift is pressed
Wili Offline
Junior Member

Posts: 5
Threads: 1
Joined: Dec 2015
Reputation: 0
#1
SetPlayerCrouching(true); not working while LShift is pressed

Hi, I'm trying to make the player force crouch using "SetPlayerCrouching(true);"

It works if the player is walking but if the player keeps running pressing Left Shift button when "SetPlayerCrouching(true);" command is called the player won't crouch.

There is any way to send "Left Shift" key to the game so I can release "Left Shift" key just before "SetPlayerCrouching(true);" command is sent?

I tried this with the same result:

SetPlayerMoveSpeedMul(0.0);
SetPlayerRunSpeedMul(0);

If the player keeps pressing "Left Shift" the player won't crouch anyway, even if the player is not moving at all.

Any ideas?

Thank you in advance!
12-23-2015, 12:58 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#2
RE: SetPlayerCrouching(true); not working while LShift is pressed

But if you hold in the Left-Shift that just means you're attempting to run. There's no script from what I know that can disable that. Where in this level are you using this script?

Derp.
12-23-2015, 01:39 PM
Find
Wili Offline
Junior Member

Posts: 5
Threads: 1
Joined: Dec 2015
Reputation: 0
#3
RE: SetPlayerCrouching(true); not working while LShift is pressed

Thanks for the answer!, well I hope there is a way, I'm just trying to make a crush trap where the ceiling goes down and crush the player, It works pretty well if the player is walking but if the player keeps running the "SetPlayerCrouching(true);" command won't work and the player clips trough the ceiling and starts bouncing.

Here is my problem:

https://youtu.be/35SR5gPfujI

The first part where the player only walks works perfect, the problem is the second part of the video where the player keeps running and "SetPlayerCrouching(true);" is not working.

Any ideas on getting this trap to work?

Thank you!
(This post was last modified: 12-23-2015, 02:16 PM by Wili.)
12-23-2015, 01:50 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#4
RE: SetPlayerCrouching(true); not working while LShift is pressed

Why don't you make that last section of the crush sequence where the player cannot move? Just disable the player controls and script the last part of the sequence.

Derp.
12-23-2015, 02:17 PM
Find
Wili Offline
Junior Member

Posts: 5
Threads: 1
Joined: Dec 2015
Reputation: 0
#5
RE: SetPlayerCrouching(true); not working while LShift is pressed

I tried SetPlayerMoveSpeedMul(0.0); and SetPlayerRunSpeedMul(0); for disabling player controls but if the player keeps pressing Left Shift "SetPlayerCrouching(true);" won't work and the player will clip anyway.

There is any other way for disabling player controls?

SetPlayerActive(false); seems to work, it feels a bit odd because the player stops responding and the player can't look around anymore, but if there is no other way I could make it using that command.

Thanks a lot for the help Neelke!!!
(This post was last modified: 12-23-2015, 02:31 PM by Wili.)
12-23-2015, 02:20 PM
Find
7heDubz Offline
Posting Freak

Posts: 1,329
Threads: 40
Joined: Feb 2013
Reputation: 41
#6
RE: SetPlayerCrouching(true); not working while LShift is pressed

(12-23-2015, 02:20 PM)Wili Wrote: I tried SetPlayerMoveSpeedMul(0.0); and SetPlayerRunSpeedMul(0); for disabling player controls but if the player keeps pressing Left Shift "SetPlayerCrouching(true);" won't work and the player will clip anyway.

Right because your just changing the speed of sprinting, your not stopping the player from sprinting.
There is any other way for disabling player controls?


SetPlayerActive(false); seems to work, it feels a bit odd because the player stops responding and the player can't look around anymore, but if there is no other way I could make it using that command.

Thanks a lot for the help Neelke!!!

Only a way to completely take away control,
void SetPlayerActive(bool abActive);
Looking through the code there sin't a way to straight up stop the player from sprinting, minus possibly taking away all control, then forcing them into a crouch, but my assumption is that that wouldn't stop them from being able to uncrouch. Maybe putting the crouch inside a looping timer that constantly forces them down into crouching? hmmm... I'd have to test it all on my end before knowing if that would 100% work, and you'd have to make sure to end that loop after they exited that area (or died) but thats a possibility.

I can't test it on my end but you could give that a go.

(This post was last modified: 12-23-2015, 09:34 PM by 7heDubz.)
12-23-2015, 09:33 PM
Find
Wili Offline
Junior Member

Posts: 5
Threads: 1
Joined: Dec 2015
Reputation: 0
#7
RE: SetPlayerCrouching(true); not working while LShift is pressed

Quote: taking away all control, then forcing them into a crouch, but my assumption is that that wouldn't stop them from being able to uncrouch.


That somewhat works, I took away all control, then force to crouch, and when the ceiling is low enough to not let the player stand up again I recovered the controls.

I didn't test the loop yet, I don't really know how to do it, I don't know much of scripting, I will study how to do it and I will try.

Thanks a lot for the help 7heDubz I'm more happy with the result now!
(This post was last modified: 12-23-2015, 11:04 PM by Wili.)
12-23-2015, 11:03 PM
Find
7heDubz Offline
Posting Freak

Posts: 1,329
Threads: 40
Joined: Feb 2013
Reputation: 41
#8
RE: SetPlayerCrouching(true); not working while LShift is pressed

Well, are they unable to uncrouch once you force them to crouch?

If not then you don't need to worry about any kind of loop.

Glad to be of service.

12-24-2015, 04:28 AM
Find
Wili Offline
Junior Member

Posts: 5
Threads: 1
Joined: Dec 2015
Reputation: 0
#9
RE: SetPlayerCrouching(true); not working while LShift is pressed

(12-24-2015, 04:28 AM)7heDubz Wrote: Well, are they unable to uncrouch once you force them to crouch?

If not then you don't need to worry about any kind of loop.

Glad to be of service.

Yes, the player is able to uncrouch, the only way the player is unable to uncrouch is when the trap ceiling is low enough, so I took player controls away, force the player to crouch and when the ceiling is low enough the player recover controls.
Player crouches and only looses control over the character like 1 second so is not that bad.
12-24-2015, 01:49 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#10
RE: SetPlayerCrouching(true); not working while LShift is pressed

(12-24-2015, 01:49 PM)Wili Wrote:
(12-24-2015, 04:28 AM)7heDubz Wrote: Well, are they unable to uncrouch once you force them to crouch?

If not then you don't need to worry about any kind of loop.

Glad to be of service.

Yes, the player is able to uncrouch, the only way the player is unable to uncrouch is when the trap ceiling is low enough, so I took player controls away, force the player to crouch and when the ceiling is low enough the player recover controls.
Player crouches and only looses control over the character like 1 second so is not that bad.

Good work-around! Idea

Trying is the first step to success.
12-25-2015, 03:13 PM
Find




Users browsing this thread: 3 Guest(s)