How to know if pawn is in the air

Hello, i’m making a first simple game where you control a ball !

Thanks to tutorials and tips from the forum i managed to get what i want. Now i’m trying to get my pawn jump and cancel other jumps if i’m already in the air. After some search, i found someone with the same issue and tried to replicate this answer ==> How to know if a pawn is falling (without using UCharacterMovementComponent)

I’m still very new so i didn’t managed to get what i want, it doesn’t seem like my lane trace is hitting something(i think ?), my ball simply stay grounded. I would appreciate any tips

Event tick 1/2

Event tick 2/2

Jump Event

Does your ball roll? Is the ball the first component inside your blueprint? Maybe the LineTrace is rotating with it and hitting something else. Can you try this:

If that works it could also be that the force for the jump is too small.

So, test the LineTrace without the boolean and check if it prints and if you can jump. If this works, add the boolean, check if it changes when you jump and then add it back to your jump action if it works.

1 Like

Yes my ball is rolling and my BP look like this (goobo is the ball)

image_2022-08-22_233521557

I have tried with vector down now, it keep printing false even on the ground, i’m just trying to detect if my ball is touching the ground. Also Is it normal that i see my linetrace like this instead of following the vector down of ball ? (it stays at player spawn)

My LineTrace

I must be a little something but i dont find the cause of my misery

would it be simpler to just check if ball is overlapping anything?

the ball must have some sort of collision component. Could check if anything is overlapped. If so, then it must not be in air (or you might check if overlapping object is of a certain type, or has a tag - just some way to identify what it is in case that matters for your project).

FOr instance, you can tag your floor static meshes and wall static meshes, that way a collision with a wall wouldn’t confuse for being grounded.

edit: i guess its not necessarily simpler than a line trace down, but if you were wanting to know what your ball hits in general for other gameplay reasons, this way you could take care of it all at once.

1 Like

@BIGTIMEMASTER I’m really noob so i’m trying to do simple for my first time but i appreciate your idea for further prototype. I get what you said i just gonna try to fix this problem first to learn !

Do you have and idea of what is wrong with my attempt of linetrace ? it’s like my linetrace doesn’t follow my ball ?

in that screenshot, why is the linetrace way up in the air?

it should come out of the center of the actor and go down, right? Is that how it is normally behaving? If not, then there must be a problem with your vector math.

I am awful with vector math so I wont attempt to correct it. But you have the debug turned on so that should identify if the line is going where it needs to go or not.

If the line trace is shooting out correctly and you see that it is indeed hitting the ground but it is not showing the little red debug square to indicate a blocking hit, then the next thing to check is that the objects which should be hit are set to block the correct trace channel.

You can see on the line trace it has a parameter about the trace channel. You’ll want to look into the static mesh objects (the floor pieces) collision details panel and ensure they are set to Block that same collision channel.

If you want more instruction there, just google “unreal collision channels” and you’ll find plenty of instructions.

1 Like

@BIGTIMEMASTER i am stupido, i indeed put my line trace from the wrong location instead of the center of the ball, thank you king

1 Like

we are all stupid, but the computer is even stupider. Thats why game dev is so hard :).

I was about to add some additional info, just fyi stuff:

quick way to check the static mesh properties - just click the floor static mesh in the viewport, press ctrl+e, and then in details panel type “collision”

if you needed to change the Collision Presets, you can select “custom” from the dropdown and edit the Trace Responses as needed.

Also note that it is possible to create custom trace channels in the project settings. This way you could put some objects on a channel just for them, so a linetrace could ignore everything except for one specific type of thing. That can come in handy sometimes. Just a possibility to keep in back of your mind.

1 Like

Thanks a lot for the explanation, i didn’t know about the custom trace channels ! i’m feeling i gonna need this very soon, have a nice day :orangutan:

Hey, the LineTrace is in the air because it starts from SELF. In this case SELf is the parent in the component list, here : DefaultSceneRoot. Either you grab the Gooboo from the list and put it in the Event graph and select its location

or you grab the Gooboo in the list and make it the new parent (drop it onto the DefaultSceneRoot).

image

And if you have those other pivots in there for the camera to stop it from rotating, you can do it like in the screenshot and then select the SpringArm and in the details panel do this:

image

1 Like

Yes tank you very much @L1z4rD89 this is what i did ! I was distracted and realised it was the problem ! I simply got the world location of goobo like in your example !

This has nothing to do with helping you, but how do you get those exec lines to look like that? Is it a plugin or something like that? They look awesome

From this plugin my bro ==> Electronic Nodes in Code Plugins - UE Marketplace

i love it and it keep everything simple. You can use it with ==> Graph Formatter in Code Plugins - UE Marketplace and ==> Auto Size Comments in Code Plugins - UE Marketplace