View topic - How can i detect unit is fully underwater?



All times are UTC + 1 hour


Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: 21 Dec 2010, 18:09 
AI Coder

Joined: 17 Mar 2008, 19:03
Location: RF
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.


Top
 Offline Profile  
 
PostPosted: 21 Dec 2010, 20:08 
Spring Developer
User avatar

Joined: 22 Sep 2007, 08:51
as much as i know, the shooting ability depends on some position of the weapon being underwater or not (don't know the name if the point).


Top
 Offline Profile  
 
PostPosted: 22 Dec 2010, 01:07 
Redacted
User avatar

Joined: 11 Jul 2007, 16:47
yep, hoijui is right (it was actually possible to shoot from the water with units underwater that couldn't be seen)

you can get a unit's full 3d position in lua


Top
 Offline Profile  
 
PostPosted: 22 Dec 2010, 12:05 
AI Coder

Joined: 17 Mar 2008, 19:03
Location: RF
There is no place for lua in C++ AI API.

I don't get one thing. Why BA's sonar station (armsonar) is floating & underwater metal maker (armuwmmm) is placed at the bottom without typical differences in their .fbi files? They both do not have waterline tag set (waterline = 0) and thus for both "floater"= false? Is it hardcoded in engine for building when its "sonarDistance" <> 0? I suspect this because for floating metal maker (armfmkr) there is "waterline" tag set which is logical and provoke no questions.


Top
 Offline Profile  
 
PostPosted: 24 Dec 2010, 00:12 
Spring Developer

Joined: 08 Oct 2006, 15:58
Quote:
But i do not know where is the center of unit


It's safe to consider pos.y the lowest point on a unit's model.

Quote:
I could use GetUnitDefHeight() & unit position


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).

Quote:
Why BA's sonar station (armsonar) is floating & underwater metal maker (armuwmmm) is placed at the bottom without typical differences in their .fbi


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.


Last edited by Kloot on 24 Dec 2010, 11:38, edited 2 times in total.

Top
 Offline Profile  
 
PostPosted: 24 Dec 2010, 11:37 
AI Coder

Joined: 17 Mar 2008, 19:03
Location: RF
Kloot wrote:
It's safe to consider pos.y the lowest point on a unit's model.

I thought it is the center of the model usually.

Kloot wrote:
You would still not be able to detect submarines

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.

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.

Kloot wrote:
They are both placed at the bottom...

Just checked this. You're right! I was under deep influence by OTA!


Attachments:
File comment: sonar stations are really underwater
screen00019.jpg [52.61 KiB]
Downloaded 2 times
Top
 Offline Profile  
 
PostPosted: 24 Dec 2010, 15:07 
Spring Developer

Joined: 08 Oct 2006, 15:58
Quote:
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.


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:

Attachment:
subs1.png [1.09 MiB]
Downloaded 2 times


Top
 Offline Profile  
 
PostPosted: 27 Dec 2010, 12:01 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
maybe GetUnitDefHeight() ?


Top
 Offline Profile  
 
PostPosted: 27 Dec 2010, 14:14 
AI Coder

Joined: 17 Mar 2008, 19:03
Location: RF
Re-read the first post.


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.