Friday, October 16, 2015

Assignment B1 Unity: Navigation & Animation


Rutgers ­ Computer Graphics Course ­ Fall 2015 ­ Assignment B1
Unity: Navigation & Animation

PART 1: Navigation

1. We designed a relatively complex environment, our environment include a simple maze field, two rooms, two bridge, two stairs, bottleneck areas, 3 height levels.
2. A navigation mesh and off mesh links for the whole environment was computed.
3. Created capsule collider prefab for the “Agent”, and several agents were used to create a crowd.
4. A mouse script was created to select and specify the destination of agents.
5. “Director” script was setup to keep track of all selected agents and send messages to each agent to move to its selected destination.
6. Two obstacles were created in the environment, they can be selected by mouse and be moved using arrow keys.
7. We manually created two off mesh links for stairs, they were used to connect different planes.
8. For moving carving, it will recalculate the navMesh carving EVERY SINGLE FRAME

     - Difference between carving and not carving:

    A NavMeshObstacle is cylindrical in shape and can move around the surface of the NavMesh with a specified velocity.

    When carving is disabled, agents will ignore the obstacle when calculating paths but will sidestep around it while moving along the path. So the obstacle will only affect the agent's avoidance behavior rather than the pathfinding.

    If carving is enabled, the obstacle will create a temporary "hole" in the NavMesh. The hole will be recognized by the pathfinding, so calculated paths will avoid obstacles.

    - When and why use carving or not carving:
    For automatically moving NavMeshObstacles, navMesh will change every single frame, as the result, agents will calculate paths every single frame. It will cause great overhead. So it's not recommended to active carving for automatically moving NavMeshObstacles.

    But for stationary NavMeshObstacle for obstacles controlled by input, navMesh will not change very frequently, the overhead is relatively much smaller. So we can active carving for these NavMeshObstacles.

    - Problems for carving and not carving:
    a. if we make all obstacle carving, moving carving may cause stuck of some agents because of recalculating path every single frame.
    b. if we make all obstacle not carving, agents may not effectively avoid obstacles.

9. In order to avoid obstacles, we can use collision detecting to predict if gents will colloid with obstacles or not. Using if the distance between an agent and obstacles < triggerDistance ( collision of agent and obstacles) to detect collision. When detecting collision, we could set the triggerDistance a little bigger so that agents could predict if it will colloid with obstacles earlier.

10. Extra credit attempt: When we active carving for the automatically moving obstacles, agents could avoid then automatically, but some agents will get stuck, especially when the calculated path going through the locus of these obstacles. The reason for this problem is that, when carving activated, pathfinding module will have to recalculate the path every frame because the navMesh is changing every fame, which is very expensive overhead. In the worst situation, agents may not get the path bacause pathfinding module is always calculating but doesn’t return path to agents, which will make the agents stay on original position.

11. Extra credit attempt: We add both NavMeshAgent and NavMeshObstacle component on the Nazgul agent. To let other "human" agents avoid the Nagzul by a rather far distance, we set the size of NavMeshAgent and NavMeshObstacle much bigger than it appears. The tricky part is that, when NavMeshAgent and NavMeshObstacle component are on the same agent, it will colloid with itself, and appears randomly on the scene. To solve the problem, we modified the height of the NavMeshAgent and NavMeshObstacle and let them have different position on y axis, so that they will not colloid with each other.

The Nazgul is the read capsule located in the center of the plane, click to slick it. Move the Nazgul like normal capsule agent.

Play Instructions:
Use mouse left click to select agent or obstacles, you can hold left Ctrl key to select multiple agents.
Use mouse right click to deselect.
For agents, after selecting, use mouse left click to select destination.
For movable obstacles, after selecting, use "←" "→" "↑" "↓" to control obstacle movement. 

Part1 Web playable demo 



(Unity Web Player maybe not supported by Chrome, recommend using another browser, such as Internet Explorer, Firefox or Opera  )




PART 2: Animation 


1. An animated human character model and animation clips were download to Unity.
2. An animator controller was created; it has several states, including idle, walk, run, jump fall and dance.
3. The animated human character prefab was created. 
4. The camera view was set to follow the character; this can be seen in the playable demo.

Play Instructions:
Use "W" "A" "S" "D"  or "←" "→" "↑" "↓" to control character's movement.
When walking, press and hold left "Shift"key to run.
When walking or running, press "Space" to jump.
When idling, press "G" for a dance.
When the character will fall down when he reach the cliff. 

Part2 Web playable demo 



(Unity Web Player maybe not supported by Chrome, recommend using another browser, such as Internet Explorer, Firefox or Opera  )




PART 3: Combine Animation & Navigation


1. The prefab in part 2 was integrated into our crowd simulator, a crowd of direct able animated characters were created.
2. When navigating the same level off mesh links, characters jump. When character navigating the drop fall off mesh links, the character will fall and roll to the ground
3. Speed is adjustable, keep press Z will let the agent run.

4. Extra credit, we Integrate the 3 scenes, and create a menu that user can select which part want to play and press ESC back to main menu.




Play Instructions:
Same with Part 1





(Unity Web Player maybe not supported by Chrome, recommend using another browser, such as Internet Explorer, Firefox or Opera  )







All-in-One Web playable demo 



(Unity Web Player maybe not supported by Chrome, recommend using another browser, such as Internet Explorer, Firefox or Opera  )


Web Player Demo Video



No comments:

Post a Comment