using UnityEngine;
public class SpikeMovement : MonoBehaviour
{
public Transform player;
public float moveSpeed = 5f;
void Update()
{
// Check if player exists
if (player != null)
{
// Calculate direction to move towards player
Vector3 direction = (player.position - transform.position).normalized;
// Move towards player
transform.position += direction * moveSpeed * Time.deltaTime;
}
}
}