Game Development Community

Collisions within units and DIF files

by Leon · in RTS Starter Kit · 09/11/2005 (5:52 am) · 10 replies

Is there a way to "restore" torque collision for RTSUnit ?

Player will only control around 6-12 units, so I dont need speed. I need acuracy. Torque 1.3 collisions were just fine, so if I could reuse them on rtsunit It will work perfect for me.

Any idea on how to do this?

Regards.

#1
09/11/2005 (11:31 am)
Just use the Player class, and move over the selection and moving code from the RTSUnit.
#2
09/11/2005 (6:30 pm)
Or AIPlayer, which already has some "move to" code. (It was the original inspiration for RTSUnit, in fact.)
#3
09/26/2005 (8:53 am)
Would this meen that one could get "exact" collision against the DTS collision mesh? I have that problem I have some parts that have to be pickable with great precission, so I thought it should be easy enough to add in a class and extend the collision checks to be say ray-triangle.

The background are that I have regions of land that will be klicked in order to move units to them (like any traditional board game), and the bounding box aproach will give errors and the regions will be hard to separate.

So my first try was to find out by looking at how projectile collision is handled and to be honest I didn't understand at all. so my second try was to look at the buildPolyList and buildConvex functions, wich didn't give me more insight in how it works. so I tried to dive into the players castRay (since my break point worked with mouse over an object at that function), and after some reading through the optimized collision test for the objects bounding box I finaly think I do understand atleast that bit. and if I'm not wrong the collision check for mouse picking goes something like:

mouse checks for collision (e.g. from on3DMouseMove, in GuiRTSTSCtrl),
check for collision in GuiRTSTSCtrl::collide, and rout the castRay to the object for which the bouning box was intersected.

but I can't seem to get an object to use the DTS-collision mesh (which I have done in maya, and named Col1 and so on (or what the name was think it was Col1, but the point is that all that should be right and the model was tested in TGE and worked fine there).

so to try and put it to a bit of better defined question: "how could I get mouse picking against a collision mesh in RTS kit?" and any idea of how to modify an existing class (say the RTSUnit) to do so would be great since I have not done that much C++ coding for torque and would rather not like to start puting all to much of it together just yet.

Hope someone can help me out.
#4
10/16/2005 (10:17 pm)
Interesting, I am trying to move the Player class collision code over to the RTSunit right now. I figured I didn't understand all the intricacies of the RTSunit well enough to port it's features to the player class and adding collision into RTSunit would be easier. Am I wrong about this and going about it bass ackwards?
#5
10/17/2005 (12:02 am)
Yeah - an RTSUnit with player collision/physics is an AIPlayer. That's where it started from. RTSUnits are just much lighter weight and more efficient - becausse they do simpler collision. It's a simple trade off.
#6
02/03/2006 (1:40 pm)
Hate to be non-compliant, but I was able to easily combine RTS and dif collision with three steps.

1)

Comment out all the code block that is wrapped by:

PROFILE_START(RTSUnit_Z);

2)

Comment out all the code block that is wrapped by:

PROFILE_START(RTSUnit_UpdatePos);

3)

And adding:

Player::updateWorkingCollisionSet();
   Player::updatePos();


before PROFILE_START(RTSUnit_UpdatePos);


Not sure what I might have broken though. Granted, this wouldn't be a good solution for many, many, many, hooligan rtsunits.
#7
03/13/2006 (11:31 am)
Eric P

I used your code above and got collisons back into the RTS SK. First of all Thanks!

But one problem I've found is that the units Z location is off. They float in midair. They'll move up when the terrain gets higher, but won't move back down again. PROFILE_START(RTSUnit_UpdatePos); code that was removed looks like where the rtsunit figures out its Z location. Don't suppose you have any ideas on how to fix the "floating" units?

Other problem is that collisions don't seem to work with triggers.

-Nick
#8
03/13/2006 (1:35 pm)
Just find the terrain height of the location they are at, and clamp them back to the terrain just like the original RTS-SK did.
#9
03/31/2007 (12:18 pm)
Which file(s) should i be altering?
#10
04/05/2007 (2:30 pm)
Gurpreet:

Assuming you merged the RTS Kit and the SDK 1.5 successfully, I altered the RTSUnit.cc file which is under C:\RTSKitMerge\SDK\engine\game\RTS, and then I compiled or "build Torgue Demo" in Microsoft Visual C++ 2005 Express Edition. So now I'm having the same problem as Univ. of Michigan Dearborn (#001.

Stephen Zepp:

I'm confused... I unclamped the units to get collision and now you want me to clamp the units back... lol. Please clarify or show how to clamp the units back while maintaining the collision. Maybe I'm just a game programming newbie.