Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

switching screenboxes

Discussion in 'Cinemachine' started by rowanMB, Jul 25, 2020.

  1. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    (im new to this forums so idk if this is the right place to ask this question)

    i have multiple scenes that need screenboxes so the cinimachine confiner so it doesnt overlap the edge of the art. i use a box collider, composite colider and the cinimachine confiner addon. whenever i write a script to move the player and camera to a diffrent screenbox once they reach the edge, it always moves the player but never the camera. is there a reason for this? and if there is can i fix it?
    or do i have to use multiple cameras and switch between them
     
    Last edited: Jul 25, 2020
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,962
    If you move the player, then the camera will automatically follow if it's tracking the player - unless something prevents it from doing so.

    Is the player the camera's target?

    Do you have multiple colliders, one for each screenbox? If so, and if you move the player to a different screenbox but don't change the vcam's bounding shape in the CM collider, the vcam will stay inside the old bounding shape.
     
  3. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    the player is the cameras target. and i had 2 screenbox colliders on each frame (screenbox colliders to keep the camera from showing unwanted frames while the player moves around (but you probobly already knew that)) however even if i moved fully into the other screenbox the camera still didnt lock onto the player.

    thanks for the tip about changing the vcams boundary screenbox.
    i just dont know how to do that :p

    (sorry i didnt respond untill just now, i hadnt checked notifications.)

    ps i made a temprory and (what i think is) sloppy fix for the camera problem by moving the same screenbox to the exact cords i need it to be at every time the player enters a new screen (using trigger colliders).

    its kinda glitchy sometimes but i just needed a temp fix so i can keep creating lvls and seeing how they look
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,962
    You can try having a separate vcam for each screenbox, and when your player moves to a new box you activate the associated vcam and let CM blend to it.

    Alternativeley, if you want to keep a single vcam, you can change the confiner shape by doing vcam.GetComponent<CinemachineConfiner>().m_BoundingShape2D - myNewConfiningBox (assuming it's a 2D camera). However, you might not get smooth blending if you do it this way.
     
  5. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    mhm that was my temp solution but its not very smooth. ill try adding multiple vcams
     
  6. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    I know its been a while since i posted on this thread but iv just got the code to work properly for the multiple vcams and it turns out if i dissable one and reactivate it for use when the player enters the sceebox, the cimemachine confiner stops working for some reason (its a really good method for switching screen boxes and i would like to use it im just wondering why this glitch happens)
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,962
    We are not aware of this issue. What version of Cinemachine are you using?
     
  8. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    let me check

    im on my project rn and i dnt know hwo to check which version of cinemachine im using, all i have are 2 cameras CMvcam1 CMvcam2 a screenbox that has a collider (the collider works before i dissable the CMvcams, then when i reactivate them they dont follow the collider would i need to dissable the collider to? mabye im dumb and thats the solution)

    however i cant currently change anything on my unity project (theres another issue im working on fixing where i cant drag and drop anything) so i cant see if that solution i mentioned will work
     
    Last edited: Aug 3, 2020
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,962
  10. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    OH thank you im really dumb
     
  11. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    2.6.0
     
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,962
    For me the confiner continues to work as I cycle the vcam between active and inactive. Is it possible that there is something unusual about your setup?

    Can you make a small lightweight project that reproduces this problem?
     
  13. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    sure ill try that
     
  14. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    weird. when i tried to recreate it, nothing happens. im gonna try slowly adding components from my original project into my recreation to see what is causing it. in the meantime here are my two scenes
    (i couldnt figure out how to atatch a script like a file)
    (this is everything i have in each of em)
    -----------------------------------------------------------------------------------------------------------------------------
    (Deleted for the sake of not taking up 90% of the entire thread)
     
    Last edited: Aug 5, 2020 at 12:51 AM
  15. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,962
    Thanks for trying, but it's very difficult for me to wade through that soup :eek:

    You can just drop files onto your post to attach them, or if you want to insert an image you can paste it directly in the message. To insert code in a readable way, use this button:

    upload_2020-8-4_17-54-58.png
     
  16. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    ooohhh ok ill do that xD sorry for the long indecypherable(idk how to spell that) post xD
     
  17. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    .
     
    Last edited: Aug 5, 2020 at 12:50 AM
  18. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,962
    That's a little better...
    Still, there are just a bunch of loose files, I don't really know how you've connected them in your scene.

    Have you tried exporting your scene as a unity package? Then I can import it into an empty project and run it as you've set it up.

    upload_2020-8-4_19-42-32.png

    Be sure to include your scene and the dependent scripts and resources
     
  19. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    oh that, wow im dumb

    ill do that xD
     

    Attached Files:

  20. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    Recreating problem
    (put a collider over a cannyon so i can actualy get to the other side)
     

    Attached Files:

    Last edited: Aug 5, 2020 at 12:54 AM
  21. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    Original scene
     

    Attached Files:

  22. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    the Original is muddied and messy (i tried to clean it up as much as i could)
     
  23. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,962
    so, if I open the original, will I see the problem? What are the repro steps?
     
  24. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    well there is a door in a tree and the goal is to have a room that it teleports you to if you push the up arrow but
    the collider breaks

    oh oops forgot to change the charicter sprite xD tolate

    if you cant tell im really bad at posting stuff on forums and not mesing it up
     
  25. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,962
    There is no scene in your package, only scripts. You have to include a scene in the unitypackage, and whatever else is needed to run it. A good way to test it is to create an empty project, import Cinemachine, then import your package and try to repro the problem. That is what I will do. If you can't do it that way, neither can I :)
     
  26. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    ok so i need to include the scenes? :p

    also i slowly started importing more things from project 1 in to see what was breaking it



    im realllyyyyyyy bad at importing stuff and explaning problems sorry for wasting ur time
     
  27. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,962
    Take your time. If you like, you can zip up the whole project and just PM it to me.
    (be sure to delete the Library folder first, Unity will regenerate it and it's huge)
    Also, please give me clear repro steps - every project is different
     
  28. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
  29. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    ok im in export package (or whatever) and i have every thing selected

    i think i did it corectly
    project 2
     
  30. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    ok it says the original is to large ill fix that
     
  31. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,962
    ok, I got it and it runs. I get an empty screen in the game view. What exactly to I have to do to see the problem?
     
  32. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    it.. hm it shouldnt be running an empty screen

    atm im trying to figure out why it runs that

    ill eventualy figure it out but it might take some time
     
    Last edited: Aug 5, 2020 at 1:38 AM
  33. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    what was the other alternative? Unziping it?
     
  34. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,962
    1. Make a copy of your entire project
    2. In the copy, delete everything except Assets, Packages, and ProjectsSettings. Do this in the file explorer, without running Unity
    3. Zip it up
    4. PM it to me (or post it here if you want the whole world to know what you're doing)
    5. Make sure to enclose precise instructions for how to see the problem
     
  35. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    i have a project that runs fine but it is to big to send here
     
  36. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,962
    When you say "runs fine", do you mean that it shows the problem? If so, you can upload it somewhere and send me a link.
     
  37. rowanMB

    rowanMB

    Joined:
    May 11, 2020
    Posts:
    52
    hmm it runs fineish im trying to test it and every time i import it into an empty project it "works" more or less but not in the way its suposto. the player can move and stuff but the cameras to large and most if not all of the scripts seem to not work accept for the player movment
     
unityunity