Hi
Can someone just tell me what’s wrong with this script? I have this attached to an NPC object which is moved via another script. I want to update an animator with the movement of the NPC.
However i get “Syntax error, ‘,’ expected” on line 17, which is the second IF statement.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NPC_Controller : MonoBehaviour
{
var old_pos : float;
public Animator animator;
void Update()
{
if (old_pos < transform.position.x)
{
animator.SetFloat("Horizontal",1);
}
if (old_pos > transform.position.x)
{
animator.SetFloat("Horizontal",-1);
}
old_pos = transform.position.x;
}
}