playMaker

Author Topic: Killed when falling[SOLVED]  (Read 5069 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Killed when falling[SOLVED]
« 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?
« Last Edit: February 24, 2014, 06:03:59 AM by jeanfabre »
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Killed when falling
« Reply #1 on: February 10, 2014, 02:40:36 AM »
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

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Killed when falling
« Reply #2 on: February 11, 2014, 06:08:27 PM »
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"
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: Killed when falling
« Reply #3 on: February 11, 2014, 06:16:18 PM »
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.

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Killed when falling
« Reply #4 on: February 12, 2014, 02:20:47 PM »
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.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: Killed when falling
« Reply #5 on: February 12, 2014, 03:24:00 PM »
Strange.
Do you have any rigid body on your character? Anything related to physics?

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Killed when falling
« Reply #6 on: February 12, 2014, 04:16:55 PM »
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?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Killed when falling
« Reply #7 on: February 12, 2014, 04:39:54 PM »
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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Killed when falling
« Reply #8 on: February 14, 2014, 07:49:50 AM »
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. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Killed when falling
« Reply #9 on: February 14, 2014, 10:06:20 AM »
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 =)
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Killed when falling
« Reply #10 on: February 15, 2014, 08:05:31 PM »
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.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Killed when falling
« Reply #11 on: February 17, 2014, 09:34:43 AM »
Maybe use the raycasts hitBool to record if it hit anything.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Killed when falling
« Reply #12 on: February 22, 2014, 03:35:47 AM »
Hi!

Thank you Lane!
It's working now! :-)

Here is the results:
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Killed when falling
« Reply #13 on: February 22, 2014, 03:37:26 AM »
The pictures was too big for one post :-)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Killed when falling
« Reply #14 on: February 22, 2014, 03:38:00 AM »
And the last one
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no