I’m going to refactor all of this code…but for now, I’m trying to figure out why my creature is lerping to the destination immediately (no matter what I set the default_speed to).
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class creature : MonoBehaviour
{
public float default_speed = 0.01f;
private Rigidbody rb;
private bool moved = false;
private Vector3 destination;
private int x, y;
public Vector3 current_pos;
float speed;
void Start()
{
rb = GetComponent<Rigidbody>();
current_pos = rb.transform.position;
x = Random.Range(-15, 16) * 10;
y = Random.Range(-15, 16) * 10;
destination.x = x;
destination.y = y;
destination.z = 0;
}
void Update()
{
patrol(); //non-aggro movement
}
void patrol()
{
speed = Time.deltaTime * default_speed;
Debug.Log(speed);
transform.position = Vector3.Lerp(transform.position, destination, speed);
}
}
speed is logging at around 0.03 in this instance…