Hi guys,
I'm currently working on an RTS game using DarkGDK (C++) and was wondering how I would create individual objects for units.
I've made a reference object and cloned it, but I don't think that's the best way to do it. Along with that, I'm not entirely sure how I would go about creating a new object per click of the mouse.
I have currently got the following:
if ( mouseclicked )
{
MouseY = dbGetTerrainGroundHeight( 1, dbMouseX(), dbMouseY() ) + 10; // Gets the Y co-ordinate which is just above ground height
dbCloneObject( unit, 10 ); // Clone the reference object and create another one with id of "unit" which is 100 to start
dbPositionObject( unit, dbMouseX(), MouseY, dbMouseY() ); // This is currently spawning it at the 2D co-ordinates of the mouse, I'm sure I'll be able to sort that though
unit++;
}
Unit Spawning (RTS)
Ok, that's awesome. So the error lies within my loop?
What happens at the moment is the same Object just moves wherever the mouse is.
What happens at the moment is the same Object just moves wherever the mouse is.
Moved to General Programming. Please be careful about which forum you post in, and take a moment to ensure you're categorizing your topics correctly. Thanks and welcome to GDNet!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement