I'm making a vr game and want a 3d minimap. I have a script for a object to follow another object with distance with a 1 to 1 scale.
What i want is that if my player moved +1 on the x axes than my capsule moves 0,1.
So something like the player position x 0,1 = capsule position.
I want my Y posision to be always the same.
I'm pretty new to this so i'm using a lot of help from google.
This is the code that i have now:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class minimapplayer : MonoBehaviour
{ public Transform leader;
public float followSharpness = 0.1f;
Vector3 _followOffset;
void Start()
{
// Cache the initial offset at time of load/spawn:
_followOffset = transform.position - leader.position;
}
void LateUpdate ()
{
// Apply that offset to get a target position.
Vector3 targetPosition = leader.position + _followOffset;
// Keep our y position unchanged.
targetPosition.y = transform.position.y;
// Smooth follow.
transform.position += (targetPosition - transform.position) * followSharpness;
}
}