How to program gravity for a pawn class with C++

I could use a character, a paper character, or a main pawn as well, however only the character class is compatible with set gravity direction node, but character class has other problems in my case. Since I cannot attach a pawn class (or default pawn) to set gravity direction node, how can I do it with C++?

Gravity must be modify all the time, by a line trace’ s normal direction, fired by the characters location. Whatever the incline of the surface the line trace hits, the gravity will be modified towards it so the character will always be able to walk in every surface(every incline) normally. You can think of my character as a slime with spiderman powers. I can provide more context if you like.

I opened lots of topics here, if you are really interested to help, you might as well take a quick look at some of them.

Since I don’t know about C++ at all, if possible (which I am not sure) I would prefer using a hybrid approach, just making the core part of the mechanic in the c++ and doing everything else in blueprint, as I said if possible. I am in need here. Thanks y’all as advance :slight_smile:

Or basically I could writed, I want to replace set gravity direction node with some code in C++ in a pawn class.

@ClockworkOcean @Mind-Brain

1 Like

In the pawn class, you can just make your own gravity code in blueprint, you don’t need C++. It’s only if you want to make changes to the player character that you’ll need it.

I have a pawn that does something like this, I’m hunting out the code…

1 Like

So replace set gravity direction node with it’s alternatives? Ok, but how exacly? Since I can’t use set gravity direction node in a pawn.

“It’s only if you want to make changes to the player character that you’ll need it.”

What does that means?

Can you see this snippet?

https://dev.epicgames.com/community/snippets/edit/KNxo

It’s enough to keep contact with the surface of a sphere, and any other shape without sharp edges

surface pawn

1 Like

It gives error 403 when I click on it. (No Access)

and now?

same

Crap

Maybe it takes a while, not sure…

Tell me if it still doesn’t work, and I’ll paste pictures…

Nope, still not working. Please

1 Like

I think you might have to login to the bar on the left of the forum page separately to be able to see the snippet, not sure.

Ok, buckle up…

Default values are

LookRate 1.25

MoveRate 7

TraceStartHeight 50

Everything else = 0

The pawn just looks like this

If there are any sharp corners, it will get stuck, but it will walk on any part of any smooth object

For instance, this

torus

If you want something that ‘feels’ square, just bevel it a bit

cube

2 Likes

I see, this seems awesome, I will try to impelent this, get ready for bunch of follow up question (joking). By the way this sytem is not what I have imagined but I think it’s better because it’s more dynamical and natural, much better than what I was trying to make. Edges are not a problem, most of 2d objects will be low resolution pixelated and there will be alot of sharp edges on the map, so probably I will just add other high quality parts for edges so it looks natural, mabe there is an effect or something for that to make it easier in Unreal. Anyways, thank you very much.

1 Like
1 Like

Why’d you delete the comment? I think whatever you write would be usefull. @gardian206

I don’t know how to make booleans into floats.

Also, Enchanted inputs are something new for me. Should I create them in content browser like a blueprint?

Right click

split

Any input that gives you float values 0-1 is fine. If you want to use Enhanced input

It’s already setup in the default players.

1 Like

@ClockworkOcean I can see your other snippets, if that snippet is yours can you resend it or something please :))

I tried unpublishing and republishing, see if that helps?

Apparently others can see it…

No, error 403 again. But I can see your other snippets?? I tried with a different account and the resoult is same. I know I am asking too much but, by any chance can you publish it in github? Plese :))