Using Unity, implement the Kinematic Arrive algorithm. Theprogram should have a character and plane on which the charactercan move. The program should also allow the user toleft-click anywhere on the plane causing the character to performthe Kinematic Arrive algorithm to move toward that spot. Oncethe character has successfully arrived and stopped at thedestination, the user should be able to click again to performanother move.
Built-in graphics and game objects will suffice (although youmust be able to tell the orientation of the character).
X 9 10 11 13 14 15 It 17 18 19 20 21 12 23 15 17 18 19 33 35 37 38 39 40 The algorithm now looks like the following: class KinematicArrive: # Holds the static data for the character and target character target # Holds the maximum speed the character can travel maxSpeed # Holds the satisfaction radius radius # Holds the time to target constant timeToTarget = 0.25 def getSteering(): # Create the structure for output steering = new KinematicSteeringOutput() #Get the direction to the target steering.velocity = target.position - character.position # Check if we're within radius if steering.velocity.length() < radius: We can return no steering request return None #We need to move to our target, we'd like to # get there in timeToTarget seconds steering.velocity /= timeToTarget # If this is too fast, clip it to the max speed if steering.velocity.length() > maxSpeed: steering.velocity.normalize() steering.velocity *= maxSpeed #Face in the direction we want to move character.orientation =
41 42 43 45 46 getNewOrientation (character.orientation, steering.velocity) #Output the steering steering.rotation = 0 return steering We've assumed a length function that gets the length of a vector.
Using Unity, implement the Kinematic Arrive algorithm. The program should have a character and plane on which the chara
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am