Hello guys Happy New Year !
I would like to know if somebody has actually write a code to detect the ground with raycast or any else method for falling event.
I explain :
I would like my player to detect the ground with the lower tick rate as possible, and when it no longer detects the ground a event is created to activate a skydive type animation, the goal being that when the player remains on the ground, the animation does not playt, but when the player jumps and the detection of the ground is too far away, the animation is activated, and the player can control the free fall.
I’ve search a tons on EPIC youtube content or Blueprint website, but not succefully, can you guys help me with that or it’s probably to technical ??
Thank you all,
Hi man
You can use linetrace by channel blueprint,
You can cast a line between the actor world location, and the same location + a vector like 0,0,-300.
This will cast a ray from your char to under him for 300 units.
Check if the ray get a hit result to start the animation or not.
I’ve seen this kind of behavior in games. Usually the player falls normally and then switches animations to a free fall or similar. Couldn’t you check how long the player has been in air so that your anim bp switches from the normal jump fall into free fall?
The raycast method works as well if you want a more instant change. Although you still need to detect distance from ground based on the player’s situation. Has the player jumped? And/or are they falling (slightly different than jump).
Binding a timer to Jump Apex could handle starting this check but if the player runs off a ledge, they fall, not jump, but would still play the falling animation. This leads back to checking for how long they have been in the air in the anim bp since it’s already doing this check per frame. And checking a float is faster than performing many line traces.
But you can just use the function “Is Falling” from Character Movement to auto detect when the character it’s falling and you don’t need to check when the character jumped and when falled from a ledge. I’ll use the line trace option.
This is true. I still prefer to check this in the anim bp since it already has a tick event being used and it is meant to change the animation state anyways. Why have the character blueprint check this when the animation needs to know about it?
Is Falling is set immediately on jump (CMC). You can use this state to trigger actor to ground checks at intervals (timer). Event on landed can be used to turn off the checks (clear timer).
When you get the desired distance simply set a transition state boolean or whatever var for your anim BP to use (state machine transitions).