Quantcast
Channel: Questions in topic: "follow"
Viewing all articles
Browse latest Browse all 536

How to link a follow script to the existing ThirdPersonCharacter animator

$
0
0
I'm trying to link a character's follow script to the existing ThirdPersonCharacter (Ethan) animator, but the animation doesn't play. I get no errors. Here is the current script, I used part of a tutorial script: using UnityEngine; using System.Collections; public class Stalker : MonoBehaviour { Animator anim; int jumpHash = Animator.StringToHash("Jump"); int runStateHash = Animator.StringToHash("Base Layer.Run"); public float followSpeed = 0.1f; public Transform followTarget; void Awake () { anim = GetComponent(); } void Update () { this.Follow (this.followTarget, fSpeed: this.followSpeed); } void Follow (Transform target, float fSpeed = 1) { Vector3 newPosition = Vector3.MoveTowards(this.transform.position, target.position, fSpeed * Time.deltaTime); AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0); if(stateInfo.nameHash == runStateHash) { anim.SetTrigger (jumpHash); } this.transform.position = newPosition; this.transform.LookAt (target.position, this.transform.up); } } I just realized the "Jump" will always be active with the current script, but i'll fix that later. If you are willing, post the script. PLEASE HELP, NEED AN ANSWER AS SOON AS POSSIBLE!

Viewing all articles
Browse latest Browse all 536

Trending Articles



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