Hello everyone,
Sorry for my english,
I am about to try to create a TopDown game Shooter, and I have a problem with the animation of the player’s legs.
The rotation of the player execute with the position of the mouse, and I can not make the animation of the legs follow depending on the position of the body …
Example :
Here is the code of the rotation player:
void LateUpdate() {
Plane playerPlane = new Plane(Vector3.up, moi.position);
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
float hitdist = 0.0f;
if (playerPlane.Raycast(ray, out hitdist))
{
targetPoint = ray.GetPoint(hitdist);
targetRotation = Quaternion.LookRotation(targetPoint - moi.position);
transform.rotation = Quaternion.Slerp(moi.rotation, targetRotation, speed * Time.deltaTime);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 100)){
if(Input.GetMouseButton(0) && peutTirer == true){
if(GetComponent<NetworkView>().isMine){
GetComponent<NetworkView>().RPC ("tir", RPCMode.All, hit.point);
}
}
}
}
}
And the code for animation legs send to Blend tree :
void Update (){
float h = Input.GetAxis ("Vertical");
float x = Input.GetAxis ("Horizontal");
//anim.SetFloat ("xrotat", targetRotation.x);
if (GetComponent<NetworkView> ().isMine) {
GetComponent<NetworkView> ().RPC ("move", RPCMode.All, x, h);
if (Input.GetKeyDown (KeyCode.F) && torcheAllu == true) {
GetComponent<NetworkView> ().RPC ("allumetorche", RPCMode.All, 0);
} else if (Input.GetKeyDown (KeyCode.F) && torcheAllu == false) {
GetComponent<NetworkView> ().RPC ("allumetorche", RPCMode.All, 1);
}
}
}
I do not know if you UNDERSTAND, I put you so this link to an example of my game.
Just click on “créer un serveur”
http://www.ricl-chatland.fr/test2/
(117Mo sorry)
Thanks for your help,
Cordialy