Language:EN
Pages: 5
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
this can the location and orientation leader chara

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

psi

psi= psipc.

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

if slot i is occupied,

otherwise,

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

# Holds the assignment of a single character to a slot struct SlotAssignment:
character
slotNumber

# Holds a list of slots assignments. slotAssignments

# A very simply assignment algorithm: we simply go through # each assignment in the list and assign sequential slot # numbers
for i in 0..slotAssignments.length():
slotAssignments[i].slotNumber = i

# Update the drift offset
driftOffset = pattern.getDriftOffset(slotAssignments)

# Add a new slot assignment
slotAssignment = new SlotAssignment()

160

Chapter 3 Movement

45
46

52 # Otherwise we’ve failed to add the character 53 return false
54

55

68 # Update the assignments
69 updateSlotAssignments()
70

71

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

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

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

The formation pattern class generates the slot offsets for a pattern, relative to its

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.

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Heidi Anderson

PageId: DOC6597EBF