This can the location and orientation leader character
3.7 Coordinated Movement 157
environments, however, the slow down required is unpredictable, and it is better not to burden the whole game with slow formation motion for the sake of a few occasions when a faster speed would be problematic.
panchor = pc + koffsetvc,
where pc is the position, and vc is the velocity of the center of mass. It is also necessary to set a very high maximum acceleration and maximum velocity for the formation’s steering. The formation will not actually achieve this acceleration or velocity because it is being held back by the actual movement of its characters.
by
pc =1 | i=1..n� | � |
|
|
---|---|---|---|---|
p′si= psi− pc.
For efficiency, this should be done once and the new slot coordinates stored, rather than being repeated every frame. It may not be possible, however, to perform the calculation offline. Different combinations of slots may be occupied at different times. When a character in a slot gets killed, for example, the slot coordinates will need to be recalculated because the center of mass will have changed.
⃗vc =1 | i=1..n� | � |
|
|
|
||||
3.7.5 IMPLEMENTATION
We can now implement the two-level formation system. The system consists of a for-mation manager that processes a formation pattern and generates targets for the char-acters occupying its slots. It has this form.
3.7 Coordinated Movement | ||
---|---|---|
|
160 |
|
|
---|---|---|
45 | ||
46 |
52 # Otherwise we’ve failed to add the character 53 return false
5455
68 # Update the assignments
69 updateSlotAssignments()
7071
84 # Ask for the location of the slot relative to the 85 # anchor point. This should be a Static structure
86 relativeLoc =
87 pattern.getSlotLocation(slotAssignments[i].slotNumber) 88
|
3.7 Coordinated Movement | |
---|---|---|
For simplicity, in the code I’ve assumed that we can look up a slot in the slotAs-signments list by its character using a findIndexFromCharacter method. Similarly, I’ve used a remove method of the same list to remove an element at a given index.
Data Structures and Interfaces
|
---|
anchor point. It does this after being asked for its drift offset, given a set of assign-ments. In calculating the drift offset, the pattern works out which slots are needed. If the formation is scalable and returns different slot locations depending on the num-ber of slots occupied, it can use the slot assignments passed into the getDriftOffset function to work out how many slots are used and therefore what positions each slot should occupy.