- Le plus récent
- Le plus de votes
- La plupart des commentaires
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?
Cette publication est fermée : l'ajout de nouvelles réponses, commentaires et votes est désactivé.
Contenus pertinents
- demandé il y a un an
- demandé il y a un an
- demandé il y a un an
- AWS OFFICIELA mis à jour il y a un an
- AWS OFFICIELA mis à jour il y a 4 mois
- AWS OFFICIELA mis à jour il y a 2 ans
- AWS OFFICIELA mis à jour il y a un an