Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Rabagast on February 09, 2014, 11:47:29 AM
-
Hi!
Is it a way to to check if the player is falling from a specific height and then kill him?
-
Hi,
Yes, you would need to implement two things:
1: a ground check system, so that you know when the player is touching the ground or not
2: a distance measurement of the current position against the position is stopped touching the ground.
With this you will be able to check falling players. I would start implement this ground check. What controller do you have for your player?
bye,
Jean
-
Hi
I have a simple controller for a platformer.
And when I push the space button, I activate the thruster. Like a game on Commodore 64, called "Space Taxi"
-
Using check if is grounded. If not get inicial Y position.
Then.
Check if is grounded. If yes get final Y position.
Float Operator Inicial-Final
Float Switch between your values.
With this you can hurt/kill your player.
Tip get position in world space.
-
Hi!
I added "Controller Is Grounded" Just to experiment a little.
But the "Controller Is Grounded" is false even if the player is on the ground. I don't understand that.
-
Strange.
Do you have any rigid body on your character? Anything related to physics?
-
I have a RigidBody to the Player. And a Thruster Script. And a Physic Material.
I also need a Character Controller for the action "Controller Is Grounded"
Do I need to do something with the ground? Does it knows automatically what is ground or not?
-
In Space Taxi it was more like running into something too fast was death rather than a Height determining the fall.
If you've got ability to go upwards in midair then last position when grounded versus new grounded position with a comparison isn't really what you want. If it's like Space Taxi death then you'd be looking for a speed at the time of a collision.
I did a little test with the Character Controller component and it doesn't seem to be returning a grounded bool correctly but I might not have set it up right or it may have some unique conditions I wasn't specifying.. You can do a grounded test by casting a very short raycast downward and if it hits something then the character is grounded, otherwise he is not. If you use that raycast result to change states you would have a falling/not falling state set that you could use to easily get the last grounded position and flow that way like the suggestions above. Basically the Character Controller wouldn't be needed if you were only using it for the ground check.
-
Hi!
You're right, Lane!
It's about the speed. But I made it.
I use a Ground Trigger. And make a FSM with these states:
In State 1 I have a Trigger Event.
In State 2 I have a Float Compare where I compare the speed.
If the speed is greater than 10, it goes to a state where the player die.
If the speed is less than 10, it goes to another state and back to state 1.
It's working very well. :)
But I don't understand the action "Controller Is Grounded" It's never grounded.
Can someone explain me why?
I will try to use Raycast. I have never used it before, but I will try. :)
-
Perfect! ;D
Yeah I don't know why the grounded bool isnt working, like I said I couldn't get the controller to flip the bool either so maybe theres some other stuff that needs to be done to work with the Character Controller or something. I never really use them, so I'd have to look into it further to confirm.
Dont be afraid of raycasts, they're really handy =)
-
Now I have tried Raycast a little bit. And it's very useful for many things. :)
But one question:
If I want to check if the player is grounded, I cast a Raycast line to the ground. And when this line is touching the ground, then it's going to a new state. But how can I check if the line is not touching anything? It's no option for that.
-
Maybe use the raycasts hitBool to record if it hit anything.
-
Hi!
Thank you Lane!
It's working now! :-)
Here is the results:
-
The pictures was too big for one post :-)
-
And the last one