Hello,
So I was looking at the DFTween Camera Shake example;
It sits on the Cube object, and it triggers a tween shake on the Camera object specified by the player.
using UnityEngine;
using System.Collections;
using DaikonForge.Tween;
public class TestShakeObject : MonoBehaviour
{
public Transform Camera;
private TweenShake shake;
private TweenBase fallTween;
void Start()
{
shake = TweenShake.Obtain()
.SetStartValue( Camera.position )
.SetDuration( 1f )
.SetShakeMagnitude( 0.25f )
.SetShakeSpeed( 13f )
.SetTimeScaleIndependent( true )
.OnExecute( ( result ) => { Camera.position = new Vector3( result.x, result.y, Camera.position.z ); } );
fallTween = this.TweenPosition()
.SetStartValue( transform.position + Vector3.up * 5f )
.SetEasing( TweenEasingFunctions.EaseInExpo )
.SetDuration( 1f )
.SetDelay( 0.25f )
.SetTimeScaleIndependent( true )
.OnCompleted( ( sender ) => { shake.Play(); } )
.Play();
}
void OnGUI()
{
GUILayout.Label( " Press SPACE to restart " );
}
void Update()
{
if( Input.GetKeyDown( KeyCode.LeftArrow ) )
{
Debug.Log( "Time scale: SLOW" );
Time.timeScale = 0.15f;
}
else if( Input.GetKeyDown( KeyCode.RightArrow ) )
{
Debug.Log( "Time scale: NORMAL" );
Time.timeScale = 1f;
}
if( Input.GetKeyDown( KeyCode.Space ) )
{
fallTween.Stop().Rewind().Play();
}
}
}
How should this be amended so that I can put the script on my camera, and just enable/disable it as needed via a PlayMaker Enable Behaviour action?