I'm designing a maze with Unity3D. The maze has a number of bifurcations and the player will stop before each bifurcation and simply choose left or right. Then an automatic animation will move the player through the next bifurcation till the end of the maze (or till a dead end).
To animate the player I'm using AniMate and C# in my Unity project. Using AniMate I'm simply creating a point-to-point animation for each bifurcation (e.g. mage below: from the start/red arrow to point 5)
My problem is that my animation script (associated to the "First Person Controller") is not working properly since physics is not respected (the player passes through walls). If in the same project I enable the standard character controls in Unity, then I can navigate in the maze with the physical contrains of walls etc... (i.e. I have colliders).
This is an example of the code I'm using when I press left to pass from starting point, trough point 1 to point 2:
void FixedUpdate () {
if (Input.GetKey(KeyCode.LeftArrow)) {
//To point 1
Hashtable props = new Hashtable();
props.Add("position", new Vector3(756f,112f,1124f));
props.Add("physics", true);
Ani.Mate.To(transform, 2, props);
//To point 2
Hashtable props2 = new Hashtable();
props2.Add("position", new Vector3(731f,112f,1124f));
props2.Add("physics", true);
Ani.Mate.To(transform, 2, props2);
}
}
What happens practically when I press the left arrow button is that the player moves directly to point 2 using a straight line passing through the wall. I tried to pass to AniMate "Physics = true" but it doesn't seem to help.
Any idea on how to solve this issue?
Alternatively... any hint on how to have a more optimized code and just use a series of vector3 coordinates (one for each point) to obtain the simple animation I want without having to declare new Hashtable(); etc... every time?
I chose AniMate simply because 1. I'm a beginner with Unity 2. I don't need complex animations (e.g. I don't need to use iTween), just fixed animations along straight lines and I need something really simple and quick to implement in a script. However, if someone has an equally simple solution it will be welcome.
thank you in advance for your help