Game Development Community

Physics for an RTS in TGB

by Christo Irving · in Torque Game Builder · 04/05/2009 (11:53 am) · 1 replies

I have two kinds of questions. The first is a detailed look at how I could implement an original physics model in my game. The other is an implied question of whether there is a simpler way to handle this.

I am attempting to create a very simple method for handling battles in an RTS situation. Imagine a small circle representing the unit, circumscribe this unit by a bubble of "personal space". In short, a dot with a circle around it. When a unit's personal space touches an enemy's, they will exchange damage in small increments over time.

This is where my problem gets complicated. I need to handle the movement during these interactions. The model I have been keeping in my mind is of a football player running into an opponent. A 'hit and spin' to be specific. Check out this video for a breakdown: Hit and Spin.

To apply this back to my project there will be no front or back to the units so the units wont have a rotation. There are two important movements in this interaction, the rotation of the two bodies around a central point between them, and the movement of that point. I think I have bored you enough with the details so I'll leave out the calculations and finaly get to the question.

Is there any way to make the two objects act as one static sprite which I can then rotate and move as a unit until one of them moves away or dies? Alternatively, is there a method of changing the center of rotation of a sprite, in this case to the point between the two units.

This is also my first attempt at creating a physics like algorithm and I'm not entirely sure how to handle the updates, do I solve for each frame (ie unit a is at x,y for each update) or can I simply initiate movements in, 'do this until' statements? Something to keep in mind, there may be more than two units involved so a unit might need to be in two or more of these relative pairs at a time.

#1
04/06/2009 (3:01 pm)
Look at the mount(...) function. That should get you what you want.