Need Help, Player Not Following Gravity

I’ve set all the settings correctly but still when I move around my player is flying across the room or climbing on walls and is very bouncy, I’ve tried increasing angular and linear damping and also tried increasing the mass still it’s the same.


Here’s the video https://drive.google.com/file/d/1aZ-AMyim9suPNoHuZqnP0hV1T3EYwC_5/view?usp=sharing

At that point you may as well just create your own character class. Very basic character class:

So I’ve created a character and attached the grabber and physicshandle components to it everything’s working well except that it’s not registering mass when I move on the PressurePlate, I’ve changed it’s massinkg to 100 still when I go on the PressurePlate the doors won’t open,
If I pick up and put some actors with more than required mass then they are opening but not when I walk on it & when I tick stimulate physics the character doesn’t move at all.


Well I think it would make more sense to use a new variable for Mass as it’s being used for gameplay elements and not physics based calculations. You could expose a public function on the character and for overlapping test if the other actor is an Escape character e.g. something like this

if (AEscapeCharacter* EscapeChar = Cast<AEscapeCharacter>(OverlappedActor))
{
    TotalMass = EscapeChar->GetMass();
}
else
{
    // not an escape character
}

I’ve created a member variable called MyEscapeCharMass but I don’t understand what you mean by “expose a public function on the character”, Can you please explain it to me much simply and maybe give another example?
Thank you


The code provided would be for the overlapping code for the door. The escape character’s get mass function would just return the member variable. e.g.

public:
    float GetMass() const { return Mass; }
private:
    UPROPERTY(EditAnywhere)
    float Mass = 100.f;

I’ve declared the Mass but I’m still confused about overlaping, like what should i declare the overlapped actors to?

It’s just an addition to your existing code for the open door component.

Ok I understand that but now I don’t know where i should add it in my opendoor.cpp, For now I added it here


And now I don’t know what i should declare AMyEscapeCharacter in the header

You need to include the header for it and it should be within the loop.

The idea is that you are checking if one of the overlapping actors is your character and if it is do something different (call your GetMass function), otherwise do as you did before.

Included the header and moved the code into the ForLoop, Got one error don’t know how to deal with it.

  • There shouldn’t be a * inside the Cast.
  • It should be the Actor you’re iterating on not the array.
  • The existing code should go into the else. As stated previously the idea that you want to do something differently if the Actor is your character.

Could you please give an example about what you want me to by the third point?

This whole discussing is an impromptu challenge so I don’t exactly want to do it for you.

Could you explain what you’re unsure of so I can give you a helping hand?

Ok Dan I really appreciate this I also want to do it by myself
I don’t really understand which part of the code you’re talking about when you say existing code and when you say iterating the actor is what I wanted an example of

The code you had that totalled the mass before making this topic.

I think it would be helpful if you explain, in plain English and in your own words, what this does

for (AActor* Actor : OverlappingActors)
{
    TotalMass += Actor->FindComponentByClass<UPrimitiveComponent>()->GetMass();
}

Getting the same errors in both cases when compiling



I think what’s happening here is, We’re getting the actors which are the overlapping actors and for those actors we’re declaring the total mass which is the total mass plus the mass of that actor

Apologies for missing your reply

Right, so what is Actor in this code?

In this code I think it’s us or any actor which is on the trigger volume i.e. overlapping on the trigger volume

Correct (though specifically it’s the current Actor that is within the OverlappingActors array that you are looping), so do you see what is wrong with what you wrote? Specifically

if (AMyEscapeCharacter* EscapeChar = Cast<AMyEscapeCharacter>, OverlappingActors)

Even if corrected for syntax:

if (AMyEscapeCharacter* EscapeChar = Cast<AMyEscapeCharacter>(OverlappingActors))

As a reminder, you want to test if the current actor is an Escape Character (which is done through this cast).

Privacy & Terms