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
899 B

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlayerVisuals : MonoBehaviour
  5. {
  6. [SerializeField]
  7. private SpriteRenderer m_apron;
  8. [SerializeField]
  9. private Transform m_moveingObject;
  10. private Camera m_camera;
  11. private Vector3 m_startScale;
  12. private void Awake()
  13. {
  14. m_camera = Camera.main;
  15. m_startScale = transform.localScale;
  16. }
  17. public void Initalise(PlayerData data)
  18. {
  19. m_apron.color = data.Color;
  20. }
  21. public void LateUpdate()
  22. {
  23. transform.rotation = m_camera.transform.rotation;
  24. transform.Rotate(new Vector3(0, 180, 0));
  25. float direction = Mathf.Sign(Vector3.Dot(m_moveingObject.transform.forward, -m_camera.transform.right));
  26. transform.localScale = new Vector3(m_startScale.x * direction, m_startScale.y, m_startScale.z);
  27. }
  28. }