So I have a ball that acts as a controller for my “blob” character, its strange though because when I press play, the collider seems to hit the ground, but my blob character seems to hover above the center. Any ideas on fixing this? Ill post my code and some images. Thank you!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAnimation : MonoBehaviour
{
public GameObject player;
Animator animator;
// Start is called before the first frame update
void Start()
{
animator = this.gameObject.GetComponent<Animator>();
}
private void Update()
{
player = GameObject.Find("Player");
if ((Input.GetAxis("Horizontal") != 0) || (Input.GetAxis("Vertical") != 0))
{
animator.SetBool("Moved", true);
Vector3 newPosition = new Vector3(Input.GetAxis("Vertical"), 0.0f, -Input.GetAxis("Horizontal"));
transform.LookAt(newPosition + transform.position);
transform.Translate(-newPosition * 10f * Time.deltaTime, Space.World);
}
else if ((Input.GetAxis("Horizontal") == 0) || (Input.GetAxis("Vertical") == 0)) { animator.SetBool("Moved", false); }
}
void LateUpdate()
{
transform.position = player.transform.position;
}
}
In Editor:
During Runtime: