Global Game Jam 2021
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

47 lines
898 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerVisuals : MonoBehaviour
{
[SerializeField]
private SpriteRenderer m_apron;
[SerializeField]
private Transform m_moveingObject;
private Camera m_camera;
private Vector3 m_startScale;
private void Awake()
{
m_camera = Camera.main;
m_startScale = transform.localScale;
}
public void Initalise(PlayerData data)
{
m_apron.color = data.Color;
}
public void LateUpdate()
{
transform.rotation = m_camera.transform.rotation;
transform.Rotate(new Vector3(0, 180, 0));
float direction = Mathf.Sign(Vector3.Dot(m_moveingObject.transform.forward, m_camera.transform.right));
transform.localScale = new Vector3(m_startScale.x * direction, m_startScale.y, m_startScale.z);
}
}