How can i detect unit is fully underwater?
Posted: 21 Dec 2010, 18:09
I could use GetUnitDefHeight() & unit position. But i do not know where is the center of unit. Engine somehow can detect a unit can't shoot when being under water.
Open Source Realtime Strategy Game Engine
https://springrts.com/phpbb/
It's safe to consider pos.y the lowest point on a unit's model.But i do not know where is the center of unit
You would still not be able to detect submarines (I assume that was the point of this question) reliably. Eg. for BA's armsubk, pos.y + height > 0 because its waterline is too small. Even the engine does not know if a unit is intended to be a submarine or a regular ship (game devs can only give it a hint in that regard, see MoveData::subMarine).I could use GetUnitDefHeight() & unit position
They are both placed at the bottom, armsonar can just be built in shallower water (minWaterDepth=10) than armuwmmm (minWaterDepth=15) so it will stick out above the surface more often.Why BA's sonar station (armsonar) is floating & underwater metal maker (armuwmmm) is placed at the bottom without typical differences in their .fbi
I thought it is the center of the model usually.Kloot wrote:It's safe to consider pos.y the lowest point on a unit's model.
Yeah, i already decided to use different algorithms for units with movedef & without. Results are fine at least for BA. The only faulty detected units are Seaplane Platforms because they are both floating and underwater.Kloot wrote:You would still not be able to detect submarines
Just checked this. You're right! I was under deep influence by OTA!Kloot wrote:They are both placed at the bottom...
That won't always work either. GetUnitDefRadius returns the radius of the model, which is auto-calculated by Spring for some model types and set manually by the modeller for others (units that do not have a defined custom collision primitive use this radius to scale their hitspheres). As an example of what to expect, see:I discovered one more reliable way. Any unit has a hit sphere. For now i don't know if GetUnitDefRadius() gives me hit sphere or smth another (can you clear up it?). So, gamedev designs a unit according to its gameplay purposes. If unit is intended to be submarine its hit sphere should not be visible outside the water. So, checking hit sphere it a sensible way to go.