Quantcast
Channel: Questions in topic: "walk"
Viewing all articles
Browse latest Browse all 88

Animation problem (noob)

$
0
0
Hey guys ;) I wanna do simple animations (walk, run, jump). I think that the script part is correct, but once I saved the script, I have an error: Assets/Standard Assets/Scripts/Camera Scripts/Movecharacter.js(51,42): BCE0019: 'animation' is not a member of 'Object'. Here is the script: #pragma strict var speed:float; var speedRun:float; var speedRotate:float; var gravity:float; var jumpspeed:float; private var controller:CharacterController; private var moveDirection:Vector3; private var deltaTime:float; private var characterContent; private var runAnim:boolean; private var run:boolean; function Start () { controller = GetComponent("CharacterController"); characterContent = transform.Find("samuzai"); } function Update () { deltaTime = Time.deltaTime; runAnim = false; if(controller.isGrounded){ if(Input.GetKey(KeyCode.LeftShift)){ moveDirection = Vector3(0,0,Input.GetAxis("Vertical") * speedRun); runAnim = true; } else{ moveDirection = Vector3(0,0,Input.GetAxis("Vertical") * speed); } if(Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.DownArrow)){ if(!runAnim){ characterContent.animation.CrossFade("walk", 0.2); } else{ characterContent.animation.CrossFade("run", 0.2); } } else{ characterContent.animation.CrossFade("idle", 0.2); } if(Input.GetKey(KeyCode.Space)){ moveDirection.y = jumpspeed; characterContent.animation.CrossFade("jump", 0.2); } } moveDirection = transform.TransformDirection(moveDirection); transform.Rotate(Vector3(0,Input.GetAxis("Horizontal") * speedRotate * deltaTime,0)); moveDirection.y -= gravity * deltaTime; controller.Move(moveDirection * deltaTime); } Thanks :)

Viewing all articles
Browse latest Browse all 88

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>