POD: Heart Diagram Exercise 02

 

Screenshot from Animation

Key Functions :

  • Camera Facing Function 
  • OffSet Animation 
  • Timeline Animation 
  • Multi Camera Layering 
  • Cinemachine 
  • Stop/Start Animation
  • Click Notation On/Off 
Scripts : 
AnimToggle Script 
using System.Collections;

using System.Collections.Generic;
using UnityEngine;
public class AnimToggleValue : MonoBehaviour
{
    public string AnimValue = string.Empty;
    public float MaxValue = 1.0f;
    private float DestValue = 0f;
    private float CurrentValue = 0f;
    public float Speed = 2f;
    private Animator ThisAnimator = null;
    private void Awake()
    {
        ThisAnimator = GetComponent<Animator>();
        DestValue = CurrentValue = 0f;
    }
    public void ToggleValue()
    {
        DestValue = (DestValue < MaxValue) ? MaxValue : 0f;
    }
    private void Update()
    {
        CurrentValue = Mathf.Lerp(CurrentValue, DestValue, Time.deltaTime * Speed);
        ThisAnimator.SetFloat(AnimValue, CurrentValue);
        //Debug lines 
        if (Input.GetKeyDown(KeyCode.Space))
        {
            ToggleValue();
        }
    }
}

Rotate Toward Camera Script  
using System.Collections;

using System.Collections.Generic;
using UnityEngine;
public class CameraFacing : MonoBehaviour
{
    void LateUpdate()
    {
        transform.LookAt(transform.position + Camera.main.transform.rotation * -Vector3.forward,
                         Camera.main.transform.rotation * Vector3.up); 
    }
}

Simple Camera Controller Script 

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class CameraFacing : MonoBehaviour

{

    void LateUpdate()

    {

        transform.LookAt(transform.position + Camera.main.transform.rotation * -Vector3.forward,

                         Camera.main.transform.rotation * Vector3.up); 

    }

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class CameraFacing : MonoBehaviour

{

    void LateUpdate()

    {

        transform.LookAt(transform.position + Camera.main.transform.rotation * -Vector3.forward,

                         Camera.main.transform.rotation * Vector3.up); 

    }

}

Leave a Reply