- Home /
Question by
Wesley21spelde · Dec 27, 2016 at 04:31 AM ·
animationanimatornot workingstreaming
anim stream problems!!
hy guys my animations are playing on the other player as well on my client When i press W or Arrow up to go Forward the animation plays for run forward i did export the scene to see if my animations are correct straming but its not!. i do use mecanim but i am new to it .
i use this code for Streaming the animations
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
if(stream.isWriting) {
//This is OUR player. We need to send our actual position to the network.
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
stream.SendNext(anim.GetFloat("Speed"));
stream.SendNext(anim.GetBool("Jump"));
//transform.FindChild("SpartanCollider").GetComponent<CapsuleCollider>().enabled = true;
}
else {
// This is someone else`s player. we need to recieve their position (as of a few
// millisecond ago, and update our version of the player.
realPosition = (Vector3)stream.ReceiveNext();
realRotation = (Quaternion)stream.ReceiveNext();
anim.SetFloat("Speed", (float)stream.ReceiveNext());
anim.SetBool("Jump", (bool)stream.ReceiveNext());
transform.FindChild("MasterChief").gameObject.SetActive(true);
transform.FindChild("MasterChief").gameObject.layer = 11;
}
}
}
i do have . anim = GetComponent<Animator>();
this is my Player Animations script So far!
public class PlayerAnimations : MonoBehaviour
{
Animator anim;
int jumpHash = Animator.StringToHash("Jump");
int runStateHash = Animator.StringToHash("Base Layer.Run");
CharacterController cc;
float speed = 10f;
float verticalVelocity = 0;
Vector3 direction = Vector3.zero;
// Use this for initialization
void Start()
{
cc = GetComponent<CharacterController>();
anim = GetComponent<Animator>();
}
void Update()
{
float move = Input.GetAxis ("Vertical");
anim.SetFloat("Speed", move);
if (cc.isGrounded && Input.GetButtonDown("Jump"))
{
verticalVelocity = jumpHash;
}
}
void FixedUpdate()
{
Vector3 dist = direction * speed * Time.deltaTime;
dist.y = verticalVelocity * Time.deltaTime;
cc.Move(dist);
}
}
What did i do wrong or forgot? can you guys help me
by the way Merry Cristmass to you all!!!
Comment
Your answer
Follow this Question
Related Questions
Animator not playing onCollisionEnter. 3 Answers
Animation in android game not working 2 Answers
Animation doesn't play 1 Answer
2D Animation does not start 1 Answer
Unable To Pause Animations 2 Answers