- Newest
- Most votes
- Most comments
I think the most common way people use to check if player in on ground (or in air) is using Ray cast.
Shoot ray cast
if(ray cast hit ground)
State is on ground
else
State in in air
https://gamedev.stackexchange.com/questions/151636/how-to-solve-the-ground-check-problem
Don't know if it's properly but maybe worth mentioning. I see that in the lua file movement controller of Jack in Lumberyard's stater game:
local thisTm = TransformBus.Event.GetWorldTM(sm.UserData.entityId);
local diff = math.abs(utilities.GetDistanceMovedDown(self.prevTm, thisTm));
if (diff < 0.001) then
self.NotReallyFalling = self.NotReallyFalling + 1;
end
self.prevTm = thisTm;
or here
-- If we're not moving up or down then we're not falling.
local zDiff = pos.z - self.landedBecauseSupportedPrevTm:GetTranslation().z;
if (math.abs(zDiff) >= 0.1) then
isFalling = true;
end
So I guessed the idea is just store the previous position then check the height between previous & current position to know if it is falling or not, but I tried commenting out these code, and see that Jack still fall & land properly, so maybe it not how it works to determine if Jack is in air, maybe I guessed wrong.
The code I see that determine if in air is slope angle
function movementcontroller:ShouldLand()
local angle, realAngle, dist = utilities.GetSlopeAngle(self);
if (realAngle < self.Properties.Falling.SlopeAngle) then
if (dist <= self.Properties.Jumping.LandingHeight) then
return true;
end
Is this a hack? I feel like this is a hack, I think Physic module should be responsible for checking if player is in air/falling.
I see that there is property m_bFlying in class CLivingEntity. Does anyone know how to get this property? Or Is this property still usable?
This post is closed: Adding new answers, comments, and votes is disabled.
Relevant content
- asked 2 years ago
- Accepted Answerasked 4 years ago
- asked a month ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 6 months ago