- Home /
Question by
mirkojpn · Aug 29, 2019 at 09:36 AM ·
uivector3coordinatesminimapnormalized
Creating Minimap Issues
Hello!
i'm trying to create minimap from a 2d sprite, i have already normalized my player position but i can't figure out how to make my marker be in the right place on my ui (it should be also in the middle of it)
my minimap is configured with circle mask and the image of my map in the second layer so i must to scroll it.
this is what i did
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MapTool : MonoBehaviour
{
[SerializeField]
private MeshFilter _map;
[SerializeField]
private Transform _player;
public Vector3 normalized;
public float width;
public float height;
// Start is called before the first frame update
void Awake()
{
width = _map.mesh.bounds.size.x / 2;
height = _map.mesh.bounds.size.z / 2;
}
// Update is called once per frame
void Update()
{
normalized = CurrentPlayerCoord();
}
private Vector3 CurrentPlayerCoord()
{
Vector3 mapCoord = new Vector3(width,0,height);
Vector3 normalizedC = (_player.position - mapCoord).normalized;
return normalizedC;
}
}
Comment
Your answer
Follow this Question
Related Questions
Draw minimap on panel 2 Answers
Editor Viewport not working since I tried splitting the Scene and Game tabs 1 Answer
Make portion of mini map camera transparent 1 Answer
Help with hold x,y,z rotation 1 Answer
Detect if UI element is visible 0 Answers