Search Unity

Priority numbers 2D RPG Game

Discussion in 'Cinemachine' started by casperborchert, Jun 12, 2019.

  1. casperborchert

    casperborchert

    Joined:
    May 9, 2019
    Posts:
    3
    Hi.
    Im new to gamedev, started a month ago, and i just started on my own RPG game, i've heard that cinemachine is a better way to handle rooms, when you enter one. Here is my progress through the entire time i've used cinemachine in this project: First i made a cinemachine camera for my starting room, and then a second room. Okay, let me cut it down a bit, how do i choose what camera i want to go to. i made a script:
    public GameObject virtualCameraEnd;
    public GameObject virtualCameraStart;

    public virtual void OnTriggerEnter2D(Collider2D other)
    {
    if (other.CompareTag("Player"))
    {
    virtualCameraStart.SetActive(true);
    virtualCameraEnd.SetActive(false);
    }
    it does work, with the transition between the first room and second room, but when i made a third cinemachine camera2D, i did the same thing, but instead of choosing my second camera i choose my third. But when ever i enter that 2dboxCollider (is trigger: yes), it activates, my second camera, not my third. It seems like it dosen't care about the "GameObject" that have been choosen, it takes the one with the highest priority, i've tried to set them all to 0, or 10 what ever. But it takes the camera with the highest priority, is there anyway to ignore make it ignore the priority numbers? Hope you understand, i'm from Denmark, so my english is not top class. Thanks

    - Casper B. Jepsen
     
    Last edited: Jun 13, 2019
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Keep all your vcams at the same default priority. When multiple vcams are active with the same priority, Cinemachine will choose the most-recently-activated one.

    So, you can configure the script for each room to increase the priority of a vcam when the player enters the trigger, and decrease it again when the player exits the trigger. Each room has a trigger that is responsible for its own vcam. If you overlap the triggers slightly, it will work very well.

    Also, take a look at the CinemachineTriggerAction script. It's made for this sort of thing, and you won't have to write custom scripts to do this.
     
    casperborchert likes this.
  3. casperborchert

    casperborchert

    Joined:
    May 9, 2019
    Posts:
    3
    I will try that, thanks for the reply. But it may take some time before i found out how to use the CinemachineTriggerAction script, because again im new. If you could be so kind to explain or tell me where i can read about the CinemachineTriggerAction script, so i can learn how to use it. Thanks Again
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    upload_2019-6-14_9-17-20.png

    upload_2019-6-14_9-17-41.png

    upload_2019-6-14_9-19-20.png

    When player enters the trigger, CM vcam1's priority will be boosted by 1. When player leaves, CM vcam's priority will go down again.
     
    casperborchert likes this.
  5. casperborchert

    casperborchert

    Joined:
    May 9, 2019
    Posts:
    3
    Gregoryl likes this.