How to check if player is in air?

0

Hi friends,

Does anyone how to properly check if player is in air?

Thanks.

質問済み 6年前200ビュー
3回答
0
承認された回答

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

回答済み 6年前
0

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.

回答済み 6年前
0

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?

回答済み 6年前

この投稿はクローズされています。新しい回答、コメント、投票の追加はできません。

関連するコンテンツ