// Update is called once per frame
public void Update()
{
if (monobitView.isMine)
{
if (monobitView.isMine)
{
// キャラクタの移動&アニメーション切り替え
if (currentAnimId == 3)
{
if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") || animator.GetCurrentAnimatorStateInfo(0).normalizedTime <= 0.55)
{
gameObject.transform.position += jumpFixedSpeed;
}
else
{
jumpFixedSpeed = Vector3.zero * Time.deltaTime;
gameObject.transform.position += jumpFixedSpeed;
currentAnimId = 0;
animator.SetInteger(animId, currentAnimId);
animator.SetFloat(moveSpeed, jumpFixedSpeed.magnitude);
}
}
else if (currentAnimId == 4)
{
if (animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion") && animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 0.90)
{
jumpFixedSpeed = Vector3.zero * Time.deltaTime;
gameObject.transform.position += jumpFixedSpeed;
currentAnimId = 0;
animator.SetInteger(animId, currentAnimId);
animator.SetFloat(moveSpeed, jumpFixedSpeed.magnitude);
}
}
else if (Input.GetButtonDown("Jump"))
{
if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") && !animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion"))
{
gameObject.transform.position += jumpFixedSpeed;
currentAnimId = 3;
animator.SetInteger(animId, currentAnimId);
animator.SetFloat(moveSpeed, jumpFixedSpeed.magnitude);
}
}
else if (Input.GetKeyDown("z"))
{
if (animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Stand"))
{
jumpFixedSpeed = Vector3.zero * Time.deltaTime;
gameObject.transform.position += jumpFixedSpeed;
currentAnimId = 4;
animator.SetInteger(animId, currentAnimId);
animator.SetFloat(moveSpeed, jumpFixedSpeed.magnitude);
}
}
else if (Input.GetKey("up"))
{
if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") && !animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion"))
{
if (animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Stand") || animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Walk"))
{
jumpFixedSpeed = gameObject.transform.forward * 1.5f * Time.deltaTime;
}
else
{
jumpFixedSpeed = gameObject.transform.forward * 3.0f * Time.deltaTime;
}
gameObject.transform.position += jumpFixedSpeed;
currentAnimId = 1;
animator.SetInteger(animId, currentAnimId);
animator.SetFloat(moveSpeed, jumpFixedSpeed.magnitude);
}
}
else if (Input.GetKey("down"))
{
if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") && !animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion"))
{
jumpFixedSpeed = gameObject.transform.forward * -0.1f * Time.deltaTime;
gameObject.transform.position += jumpFixedSpeed;
currentAnimId = 2;
animator.SetInteger(animId, currentAnimId);
animator.SetFloat(moveSpeed, jumpFixedSpeed.magnitude);
if (animator.GetCurrentAnimatorStateInfo(0).normalizedTime <= 0.0f)
{
animator.Play(Animator.StringToHash("Walking@loop"), 0, 1.0f);
}
}
}
else
{
if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") && !animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion"))
{
jumpFixedSpeed = Vector3.zero * Time.deltaTime;
gameObject.transform.position += jumpFixedSpeed;
currentAnimId = 0;
animator.SetInteger(animId, currentAnimId);
animator.SetFloat(moveSpeed, jumpFixedSpeed.magnitude);
ChangeFace("default@sd_generic");
}
}
if (Input.GetKey("right"))
{
if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") && !animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion"))
{
gameObject.transform.Rotate(0, 30.0f * Time.deltaTime, 0);
}
}
if (Input.GetKey("left"))
{
if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") && !animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion"))
{
gameObject.transform.Rotate(0, -30.0f * Time.deltaTime, 0);
}
}
if (Input.GetKeyDown("x"))
{
if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Jump") && !animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Emotion"))
{
MonobitNetwork.Instantiate("Cube", transform.position, transform.rotation, 0);
}
}
animator.SetLayerWeight(1, currentFace);
monobitView.RPC("SetFaceID", MonobitTargets.OthersBuffered, currentAnimId, currentFace, currentFaceName);
}
}
}