|
Post by tharindu on Aug 31, 2018 11:57:58 GMT
[Invector Quick Integration]
CINEMACHINE AND TIMELINE - DRIVING CINEMACHINE SIDE BY SIDE WITH INVECTOR TPCHey guys, I wanted to do this for a while now, but Unity 2018.1 stability and the continuous changes in Cinemachine kept me far from it. Now that everything has stabilized in the form of Unity 2018.1 the time was ripe to attempt a newer integration technique, and I must say, it worked like a charm. The below video is my documentation to you on driving a cinemachine timeline experience while keep the invector 3rd person controller side by side, so you can get the best of both worlds. Enjoy!
The code below is for the TimelineTriggerZone used in the video. Note that this script is taken directly from the 3D Game Kit from Unity and they own all rights to the script below. The 3D Game Kit is an absolute must have and you will learn quite a lot from it, if you have the will to learn. using System;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Playables;
[RequireComponent(typeof(Collider))]
public class TimelineTriggerZone : MonoBehaviour
{
public enum TriggerType
{
Once, Everytime,
}
public bool startOnAwake;
[Tooltip("This is the gameobject which will trigger the director to play. For example, the player.")]
public GameObject triggeringGameObject;
public PlayableDirector director;
public TriggerType triggerType;
public UnityEvent OnDirectorPlay;
public UnityEvent OnDirectorFinish;
protected bool m_AlreadyTriggered;
public void Start()
{
if (startOnAwake)
Begin();
}
void Begin()
{
OnDirectorPlay.Invoke();
director.Play();
m_AlreadyTriggered = true;
Invoke("FinishInvoke", (float)director.duration);
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject != triggeringGameObject)
return;
if (triggerType == TriggerType.Once && m_AlreadyTriggered)
return;
Begin();
}
void FinishInvoke()
{
OnDirectorFinish.Invoke();
}
}
|
|
|
Post by tharindu on Aug 31, 2018 13:29:00 GMT
|
|
|
Post by witcher on Sept 1, 2018 11:06:08 GMT
Great tutorial. How do you determine when timeline has ended if you dont use timeline trigger zone. Lets say i wana play a cutscene as soon as game starts and then how do i know when timeline has ended i mean is there a way to fire an event from timeline when it ends?? I do know i can fire an event after X secs after game start but i wana know if there a proper way to do this within timeline
|
|
|
Post by tharindu on Sept 1, 2018 16:26:14 GMT
Great tutorial. How do you determine when timeline has ended if you dont use timeline trigger zone. Lets say i wana play a cutscene as soon as game starts and then how do i know when timeline has ended i mean is there a way to fire an event from timeline when it ends?? I do know i can fire an event after X secs after game start but i wana know if there a proper way to do this within timeline I had the same question, because I wanted to trigger a cinematic upon scene entry, have the player's scripts, the hud and everything disabled till it ends. Simply add a public bool variable to the trigger script, and in the OnEnable method of the script, check if the boolean is set to true, and do the same thing in the OnTrigger method. You can use the same script and the events that come with it. I would recommend having the third person input scripts, and the hud object disabled by default. Enable after the director has ended playing.
|
|
cyhak
Full vMember
Posts: 80
|
Post by cyhak on Sept 5, 2018 16:28:45 GMT
THANK YOU THIS IS AMAZING !!!
|
|
|
Post by missbig on Sept 26, 2018 1:35:26 GMT
This is a great tutorial but does anyone know how to do the same thing but with cinema director. I do want the same thing though.
|
|
lara
New vMember
Posts: 7
|
Post by lara on Jun 6, 2019 21:23:41 GMT
Hi, awesome job, sorry for the utterly late reply. I guess I was on an unity strike ;) All the best
|
|
|
Post by deidrereay on Jan 29, 2020 17:38:51 GMT
Great tutorial. How do you determine when timeline has ended if you dont use timeline trigger zone. Lets say i wana play a cutscene as soon as game starts and then how do i know when timeline has ended i mean is there a way to fire an event from timeline when it ends?? I do know i can fire an event after X secs after game start but i wana know if there a proper way to do this within timeline I had the same question, because I wanted to trigger a cinematic upon scene entry, have the player's scripts, the hud and everything disabled till it ends. Simply add a public bool variable to the trigger script, and in the OnEnable method of the script, check if the boolean is set to true, and do the same thing in the OnTrigger method. You can use the same script and the events that come with it. I would recommend having the third person input scripts, and the hud object disabled by default. Enable after the director has ended playing. Hey followed the tutorial and everything seems Great! Worked like a charm only one thing I am noticing however..
I have the trigger set to once it plays perfect but after the cutscene has played if the player walks back through the Box collider trigger zone the camera kinda glitches real quick. Any ideas? I cant seem to figure out what is going on.
|
|
|
Post by tharindu on Feb 5, 2020 16:51:20 GMT
I had the same question, because I wanted to trigger a cinematic upon scene entry, have the player's scripts, the hud and everything disabled till it ends. Simply add a public bool variable to the trigger script, and in the OnEnable method of the script, check if the boolean is set to true, and do the same thing in the OnTrigger method. You can use the same script and the events that come with it. I would recommend having the third person input scripts, and the hud object disabled by default. Enable after the director has ended playing. Hey followed the tutorial and everything seems Great! Worked like a charm only one thing I am noticing however..
I have the trigger set to once it plays perfect but after the cutscene has played if the player walks back through the Box collider trigger zone the camera kinda glitches real quick. Any ideas? I cant seem to figure out what is going on.
I am assuming it's because the camera is colliding with it. Can you try setting the layer of the trigger zone to Triggers ?
|
|
|
Post by deidrereay on Feb 5, 2020 17:44:01 GMT
Sorry I forgot to update. That is exactly what the problem was. Didn't change the layer to Trigger
|
|
|
Post by rh4invector on Apr 2, 2020 6:37:46 GMT
You wrote that, "Note that this script is taken directly from the 3D Game Kit from Unity and they own all rights to the script below."
I'll try to contact Unity directly to ask also, but do you know if 3D Game Kit gives you the license to use in commercial games or not?
(Some assets I understand how to check if it gives you the license or not, but I'm not sure about this one).
|
|
|
Post by deidrereay on Apr 2, 2020 16:36:34 GMT
Pretty sure anything on the asset store gives that right. you just need to check if you need to9 purchase multiple seats? Correct me if I am wrong guys?
|
|
|
Post by y2splashy on Apr 12, 2020 15:49:08 GMT
Hi this is great stuff but does anyone know how to integrate invector with cinema director, thanks really appreciate it.
|
|
|
Post by deidrereay on Apr 13, 2020 19:17:37 GMT
Hi this is great stuff but does anyone know how to integrate invector with cinema director, thanks really appreciate it. Haven't tried that yet. would assume somewhat along the same lines as cinemachine (as far as having to do with cameras and such)
|
|
|
Post by lokiare on May 23, 2020 11:16:49 GMT
I've got this working in Unity 2019, but it doesn't switch back to the Invector camera after it finishes, is there something I need to do to make it swap back?
|
|