Search Unity

Camera Controller Release

Discussion in 'Assets and Asset Store' started by Tryz, Dec 21, 2013.

  1. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    I've been using this for a long time in my game, because it works great! I have a strange issue that now a second user has reported while I was watching his live stream, thought I'd ask maybe you have an idea?

    There are caves in my open-world game that when entered turn off the surface world mechanics, so sky, weather, and a lot of things, resulting in a much higher FPS while in caves in most cases. That's really the only difference I can think of is why I bring it up. It seems for some reason though that mouse DPI ratings can become quite different when underground.

    This isn't something that I or most players notice, so I think it has to do only with really high DPI "gamer" mice? Mine is just a standard mouse and there's no noticeable difference above or below ground... Or maybe something to do with having a controller plugged in or something?

    There really is no code that changes anything related to mouse sensitivity between above ground and below ground, so I assume it must be something + the FPS increase? Then again... when he would open the menu (cursor lock off) the DPI would seem to go back up... Makes no sense to me =o=
    Hope that makes some sense to you o/
     
  2. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Sorry for the long delay. I do most of my support work on the weekends.

    Unfortunately, I'm not really sure.

    I get all the input directly from Unity and Unity handles the scaling of the input itself. Then, it provides the value when someone calls for it.

    For example, if you look in my UnityInputSource.cs at line 136 you'll see I just use Unity's GetAxis() function:
    float lValue = UnityEngine.Input.GetAxis("Mouse X");

    Unfortunately, I don't have a high DPI mouse either and I'm not seeing any issues in my tests. What's good is that you can modify my code in one place to get Unity's input however you want. In the Unity Input Source, you can change the ViewX and ViewY properties to get and modify the Unity values. That should give you a place to test and customize if needed.

    I hope that helps.
     
  3. oxmhpark

    oxmhpark

    Joined:
    Feb 16, 2017
    Posts:
    2
    Hi! Your assets are all look great. I have some other author's controller assets but wish to try ootii series. Only my consideration is: Camera Controller needs real camera component? I mean, can I use cinemachine virtual camera instead of?
     
  4. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I haven't played with Cinemachine. So, I can't answer that specifically.

    The Camera Controller is like a camera rig or dolly. You make the "Main Camera" GameObject a child of the Camera Controller GameObject. Then, I move and rotate the Camera Controller. So, it depends on how you place Cinemachine in the scene.
     
  5. BlackManatee

    BlackManatee

    Joined:
    Jun 13, 2013
    Posts:
    82
    I'm using Unity 2019, NET 4.0, and HLAPI 1.02, and I've come across a possible compatibility issue. I've emailed you about the issue but, in the meantime, I may have found a short-term fix.

    When I first installed Camera Controller, the demo scenes were unable to run at all. The Camera Controller component instead reported that it was unable to function due to a scripting error.

    The only red-text error showing in the console was related to Multiplayer HLAPI. I updated my HLAPI version from 1.02 to 1.04 (in the Package Manager), and the red-text error resolved itself. After that, I was able to run the demo scene, but the Camera Controller component didn't look anything like your description / screenshots in the User's Guide. Instead, it just showed a long list of the individual parameters (kind of like what I'd expect to see when using "Debug" view in the Inspector). The demo scenes also lacked some of their functionality -- e.g., no mouse-button panning in the MOBA demo.

    Incidentally: I'm not sure if this is relevant or not, but I tried Camera Controller in Unity 2018.3.3 and the user-interface worked exactly as shown in the user's guide. One other difference between my 2018 and 2019 versions is that my Unity 2018 installation (which ran Camera Controller properly) is using the ".NET 3.5 Equivalent" scripting runtime version, but my Unity 2019 installation is running ".NET 4.0".

    Back to Unity 2019 (and NET 4.0): like I said, the demo scenes mostly worked, but the Ootii interface elements were still missing from the component in the Inspector view. I checked through some of the (~15) yellow/warning errors, most of which were related to "obsolete" methods or syntax -- but I did find one script element that seemed especially important: the EditorCoroutines script uses "WWW" rather than the new term "UnityWebRequest." I added a "using UnityEngine.Networking" line to the script, and changed WWW to UnityWebRequest, and recompiled.

    At that point, I got another red error message, saying that "The type or namespace name 'DemoProperties' could not be found." I simply moved the three demo scripts out of the Scripts/UI folder and put them into the Scripts/Editor folder. Once I did that, the problem appeared to be solved: the Camera Controller component in the Inspector now matches the screen shots from the User's Guide, and the demo scenes appear to function properly.

    Sorry for the long post! I'm explaining all this in (painfully long!) detail because my coding skills are largely self-taught, and I'm not certain which steps are relevant to the problem and its solution. Hopefully, Team Ootii will be able to patch the glitch soon -- but until then, perhaps the process I've described may be helpful to other folks who have a similar problem.
     
  6. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    @BlackManatee - which Unity 2019 version are you using? I've used it up to 2019.1.8f1 and I haven't seen such an error (I always use the .NET 4 runtime). I haven't tried any of the 2019.2 versions yet.

    I'll be spending some time over the next couple of weeks looking into a few issues that have come up recently, as well as testing everything out with the most recent Unity versions.
     
  7. BlackManatee

    BlackManatee

    Joined:
    Jun 13, 2013
    Posts:
    82
    Thanks for the quick reply! I'm using Unity 2019.1.5f1.

    I uninstalled, restarted, and reinstalled the package a couple of times last night, in an effort to replicate the problem. From what I could see, it consistently happened under a certain set of conditions:
    1. Install Camera Controller into Unity 2019.1.5f1, with .NET 4 runtime, and HLAPI v1.02
    2. Update HLAPI from v1.02 to v1.04 (this will allow the demo scene to run, but the Ootii interface elements are missing in the Camera Controller component in Inspector view).
    3. Revise "EditorCoroutines.cs" to add "using UnityEngine.Networking" plus replace "WWW" with "UnityWebRequest".
    4. Project will recompile, but red warning message says it can't find "DemoProperties" type/namespace.
    5. Move all 3 script files from "Assets/ootii/_Demos/Shared/Scripts/UI" to "Assets/ootii/_Demos/Shared/Scripts/Editor."
    6. Project works fine now, with the Camera Controller's interface matching what's shown in the CC User's Guide.
    Hope that helps narrow down the problem! My (totally uneducated) guess is that the tool runs fine in Unity 2018 / .NET 3.5 / HLAPI 1.02 because the older environment tolerates the (previously valid) syntax and locations, but Unity 2019 / .NET 4.0 / HLAPI 1.04 requires the updated syntax/paths. . .
     
    Last edited: Aug 23, 2019
    TeagansDad likes this.
  8. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    @BlackManatee - I was able to replicate the issue following your instructions -- except that I didn't run into any problems with the scripts under _Demos. I just commented out the lines that referenced WWW in EditorCoroutines.cs. If you're getting an error message about not being able to find the "DemoProperties" type, check that the "ootii.Demos" assembly definition file is present in Assets/ootii/_Demos/

    If you're just using Camera Controller and not Motion Controller, you can just delete both EditorCoroutines.cs and EditorCoroutineExtensions.cs, as nothing in Camera Controller references them. Only the Character Wizard (part of Motion Controller) actually uses them; I think they got included by mistake at some point. I'll make sure that the obsolete references to "WWW" are removed in the next release.

    For that matter, you don't actually need any of the files under Assets/ootii/_Demos/Shared/Scripts for Camera Controller. A few of the Motion Controller demos use them for displaying the demo instructions, but none of the CC demos do at this point in time.
     
    Tryz likes this.
  9. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I'm not having any issues on Unity 2019.2.0f1 and .Net 4.x (without HLAPI update) out of the box. So, it must be the HLAPI v1.04 that's causing the issue.



    Based on this Unity post, HLAPI isn't supported in Unity 2019.
    "The HLAPI will no longer ship with Unity after 2018.4 (LTS)"

    Unfortunately, I'm guessing the HLAPI 1.04 is introducing an issue in Unity's rendering of the inspector.
     
  10. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Yeah, when I set up a new project to test this out, I accidentally created it with Unity 2019.2.0f1 and I didn't have any errors. I realized that I should have created it in a Unity 2019.1, and when I recreated it in 2019.1.5, I was able to replicate it -- even without updating to HLAPI v1.04; it was doing it with the default HLAPI v1.02.
     
    Tryz likes this.
  11. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Good find. So, it sounds like the answer is really... update to Unity 2019.2.0f1. Unity 2019.1.5 probably has a bug.
     
  12. Pandur1982

    Pandur1982

    Joined:
    Jun 16, 2015
    Posts:
    275
    Hello i have a question, i use the Mobs setting from the camera for a top down game project but how can i rotate the camera, i found no setting for that.
     
  13. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hi. The MOBA camera doesn't rotate. I mirrored it off of DOTA2's camera and it doesn't rotate.

    You can create your own camera motor based on mine and add rotation, but it's not a feature I promote out of the box for that motor.
     
  14. Pandur1982

    Pandur1982

    Joined:
    Jun 16, 2015
    Posts:
    275
    Ah ok i understand, thx for your answer.
     
    Tryz likes this.
  15. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    The camera itself is a sub-object of the controller (in my experience/setup) so you should probably only need to apply a RotateAround the y axis to the camera based on input to achieve the desired results. @Pandur1982
     
    Tryz and Pandur1982 like this.
  16. BlackManatee

    BlackManatee

    Joined:
    Jun 13, 2013
    Posts:
    82
    Quick scripting question re Camera Controller, @Tryz

    I'm trying to set the target for a LookAt motor type, via script. Here's what I tried:

    racerCamLookAtMotor = cameraRig.GetComponent<com.ootii.Cameras.LookAtTargetMotor>();
    racerCamLookAtTarget = racerCamLookAtMotor.Target


    I have no trouble getting the other types of fields to populate at runtime (e.g., Anchor, etc.), but there's apparently no explicit connection that will allow me to (easily) fill the "Target" of a LookAt camera controller.

    Is there a quick hack I can use? I'm a learn-as-I-go coder, so I tend to steer clear of things like serializing and get/set, etc, at least for now. ;-)

    UPDATE: Sorry, but you can probably ignore all the questions and hints etc, here and below. ;-) After two days of fiddling around (and eventually buying EasyInput to see if it would help!), I finally gave up and looked for another solution. I hadn't realized CineMachine provided gameplay cameras (I had always thought it was specifically for cutscenes). I gave it a try, and it seems to do everything I need, in a simpler way (plus there's a pre-made bridge for ReWired).

    Thanks anyway!
     
    Last edited: Sep 12, 2019
  17. BlackManatee

    BlackManatee

    Joined:
    Jun 13, 2013
    Posts:
    82
    Just FYI, I came up with a quick workaround -- totally inefficient, I'm sure, but it works. ;-)

    Instead of directly populating the "target" field at level start-up (the player/target doesn't actually appear until then), I added an intervening object to the scene and dragged that into the Ootii LookAt motor's target field. I then added a simple (standard asset) FollowTarget script to the intervening object, and scripted it to follow the player once they appear. In that way, the interval target listens for the incoming player, follows it, and then the Ootii LookAt motor is, in essence, following the player.
     
  18. BlackManatee

    BlackManatee

    Joined:
    Jun 13, 2013
    Posts:
    82
    Here's another tip that may help folks who use this tool while editing with Unity's "Dark" color scheme: I was totally unable to get CameraController's "Debug" mode to work - neither in Unity 2019.1.5 or 2018.3.3. Checked the documentation several times, reinstalled, etc., but no dice.

    After an hour of fiddling and cursing, I finally noticed the little black bug icon you show in the Camera Controller's component, in the documentation. The instructions don't say that you actually have to CLICK the bug icon, just that you have to check the "show debug info" box under the debug icon. That section was apparently missing on my installations - or so I thought.

    Happy ending, though: I finally tried clicking in the empty area to the right of the "advanced" button -- and I stumbled on the hidden bug button. Here's what the (invisible) icon looks like for folks using the Dark editor theme:

    upload_2019-9-11_10-23-17.png

    Please be sure to double check your UI setups to make sure that your graphics/icons/text/etc are compatible with both of Unity's color schemes. Thanks!
     
  19. BlackManatee

    BlackManatee

    Joined:
    Jun 13, 2013
    Posts:
    82
    One more question, for your weekend enjoyment! ;-)

    To recap - My 1st question is how to populate the Target field in a LookAt motor, via script. I have a workaround, but can't get a direct scripting command to work.

    My 2nd question is whether there's a way to create Action Aliases to activate a camera motor -- via the CC Inspector fields, rather than via script. It seems like it should be a no-brainer, but I've bought both CameraController and EasyInput, and neither seems to have a way to activate a specific camera (e.g., the 3rd person follow cam, switching away from a 1st-person cam).

    If each camera had an Action Alias that simply activated it, that would be great. I could then easily map the alias just like the other ones you've implemented, either in EasyInput or Rewired.

    Speaking of Rewired, here's my 3rd question: is there any way to simply plug Rewired's Input Manager prefab into the Camera Controller's "Input Source" field? Your docs say that the products are compatible with ReWired, but it's not possible to pull the Rewired prefab into CC's Input Source (apparently ReWired lacks a standard component which CC is looking for in order to consider it a valid Input Source). I'm not seeing anything beyond some general script instructions that would require me to remap all of my Rewired keymaps manually (which is definitely not a time saver!).

    Ironically, I found that another provider has more details on EasyInput integration than your docs provide. As an example of how you might carry this out, here's the documentation for using EasyInput with Malbers' animation packages: https://docs.google.com/document/d/...Pw6T2JeZiCikCfuSI/edit#heading=h.3tue5saqox44

    Any thoughts/suggestions?
     
    Last edited: Sep 12, 2019
  20. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    @BlackManatee - I'm just heading out the door, so forgive the terseness of my answers

    1. I think I've done this before, but I need to spend a bit of time with it. I'll try and do that soon

    2. As far as I know, there isn't any such feature. But you are right that it would be useful. I'll look into it.

    3. I assume you're using the Rewired integration from the Motion Vault? It implements the IInputSource interface so calls to GetComponent<IInputSource> will work... But the Unity inspector won't allow assigning objects as an interface. That's just a limitation of Unity's serialization model. You could write a small component that gets the Rewired input source and then assigns it to the Camera Controller's input source.
     
  21. BlackManatee

    BlackManatee

    Joined:
    Jun 13, 2013
    Posts:
    82
    Thanks! But please don't worry about making any specific adjustments on my account -- I'm afraid I've gone ahead and joined the Borg ;-) -- as mentioned above, I grabbed a copy of Cinemachine, and it plays nicely with Rewired straight out of the box, and I'm having a reasonably easy time adapting my gameplay scripts to it.

    OTOH, in terms of a suggestion for improvement, I'd have to say that Issue #2 is really key: you've put together a very appealing interface, and non-programmers will assume that between-camera transitions would be handled in the editor rather than having to hand-code them. The product, IMO, will be a lot more user-friendly if you can implement some more inspector-based functionality.

    Thanks again!
     
  22. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey @BlackManatee ,

    I know you moved on, but I wanted to respond just in case. The problem is your code is off. Check out the documentation on page 28.

    You want to grab the Camera Controller first, then the specific motor, and then you can access the properties. Like this:
    Code (CSharp):
    1. CameraController lCC = cameraRig.GetComponent<CameraController>();
    2. LookAtTargetMotor lMotor = lCC.GetMotor<LookAtTargetMotor>("My Motor");
    3. Transform lTarget = lMotor.Target;
    Your code was trying to go straight to the motor without going through the Camera Controller.

    For #2, you can do some transitions in the editor. For example, if you set the Action Alias to a Unity Input Manager entry you want to trigger the transition. For example, I use the right-mouse button when I target to trigger the transition.



    I appreciate the feedback. People use the assets in lots of different ways. So, I try to give examples in the documentation and hopefully people can connect that to their situations. However, you're right... there's always more I can do to make it easier for users.

    Best of luck to you.
     
  23. Tarball

    Tarball

    Joined:
    Oct 16, 2016
    Posts:
    166
    Hi, great product. Quick question: Can you define the IMessage entries on your event system please? What is Motor Test Activate Event? What is Motor Activated Event? What is Motor Deactivated Event? What is Action Triggered Event?

    I mean I want to switch to first person on a button press or if _Camera.fieldofview < 10, but I'm confused as to what all of those IMessages represent. Would it just be easier to code everything? Thanks

    Edit: I just saw the conversation above. It seems I was going about this all wrong and I'm supposed to use transitions. I see that in the manual, and it is pretty straightforward.

    Edit #2: OK, I think I have it all figured out now, except pitch. I can't find the alias for pitch anywhere. My yaw is tied to character rotation in both 1st and 3rd person, but pitch does nothing unless I hold one of the mouse buttons... I want a "free look" cam, so I don't want to have to press anything to move the camera like 1st or 3rd person shooter. I can't seem to figure out how to have free pitch.
     
    Last edited: Sep 22, 2019
  24. Tarball

    Tarball

    Joined:
    Oct 16, 2016
    Posts:
    166
    So, now I have two problems I can't quite figure out. If you can help, I'd appreciate it.

    1) How to disable the button press before yaw/pitch of camera? I tied yaw to character movement, but pitch only works when I click the mouse. I'm using rewired and the rewired plugin downloaded from site, if it matters.

    2) When I switch from 1st to 3rd person and rotate my character during the transition, when the transition finishes, the character is rotated by that amount, semi-permanently; i.e., the camera is not necessarily aligned behind the character anymore. How can I prevent this?

    Edit: Problems solved -- it had to do with the IsViewingActivated default input variable. I fiddled with a few other settings and got just what I needed. Great asset.
     
    Last edited: Sep 22, 2019
  25. Tarball

    Tarball

    Joined:
    Oct 16, 2016
    Posts:
    166
    Did you ever figure that out? I found this in the Rewired-Ootii integration script, and it worried me. I don't know if the FPS dependency is in the Ootii source as well due to the contradictory nature of the commented portion.

    https://imgur.com/a/7v0ieJx

     
  26. LumoKvin

    LumoKvin

    Joined:
    Sep 28, 2019
    Posts:
    195
    I just bought the camera controller from Ootii - https://assetstore.unity.com/packages/tools/camera/camera-controller-13768

    With the Ootti Camera Controller rig, the left and right input cause the Character to run to the left and right wall. This is not what I want. When using the prefab camera from the Unity Standard Assets, the left and right input cause the character to run in a circle. This is the behavior that I want. I want this behavior, but I want to use the Ootii Camera Controller rig.

    Ootii camera rig: https://imgur.com/a/vwZIxMS
    Unity prefab cam: https://imgur.com/a/Y0INMVk

    I am not changing anything except the camera controller. I don't understand why changing a camera would alter the way that the input works. Why is this happening and how can I fix it?
     
    Last edited: Oct 23, 2019
  27. LumoKvin

    LumoKvin

    Joined:
    Sep 28, 2019
    Posts:
    195
    I am new to Unity and I am looking for turn-key solutions, because I don't like debugging the code that I write.

    I bought the "Third Person Motion Controller" but I am confused. I spent about 4 hours trying to figure it out. What did I just buy? I feel like I may have stumbled upon something valuable. It is like when your friend gives you some bitcoin - you sense that it is valuable but you don't really understand what it is or how to use it.

    I thought I was just buying various animation controllers along with the animations. It comes with one humanoid animation controller. Climbing the wall and other objects is pretty cool.

    Can you explain what this asset is (as if you were explaining it to a 5 year old)? Does it override the Camera Controller asset or do both work together?
     
  28. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    @LumoKvin - Motion Controller is a third person character controller; it handles character movement and animation. It includes two very basic camera controllers (Orbit Rig and Follow Rig), but neither are generally going to be robust enough to use in an actual game.

    Camera Controller includes a very basic character controller (it's used in the demo scenes), but again, it's generally intended for simple demos and prototypes.

    Motion Controller and Camera Controller are designed to work together to give you more advanced and full-featured setup.

    The best way to see how all of it works is to use the ootii Character Wizard to quickly set up a demo scene. You can access it via Windows -> ootii Tools -> Character Wizard (you can drag and drop a character model into the corresponding field). You can also start the Wizard by right-clicking on a character model or prefab in your Project view and selecting "ootii Character Wizard" near the bottom of the pop-up menu (this will assign the model or prefab automatically). When Camera Controller is present, it will be set up for you and you can see how the two assets work together.

    There are also several Motion Packs available for Motion Controller: Sword and Shield (includes the basic melee combat system), Archery, Shooter, Spellcasting, and Swimming. The Character Wizard detects which are present and provides options for setting those up as well.
     
  29. LumoKvin

    LumoKvin

    Joined:
    Sep 28, 2019
    Posts:
    195
  30. LumoKvin

    LumoKvin

    Joined:
    Sep 28, 2019
    Posts:
    195
    How do I add a bit of spring/lag to the camera?
     
  31. unity2

    unity2

    Joined:
    Jan 10, 2013
    Posts:
    23
    Hi,

    I must say it is a great product.

    But I have one problem. In my game, game camera is following a ball and after completing any stage, the ball is reseting to origin again. But as I used lerp to follow, camera follow to original position but I want to reset it to initial position. How can I reset my camera to initial position forcibly?
     
  32. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    How should I zoom to my character's shoulder? There should be a target field for zooming too because now when I zoom camera it zoom on my character's as*s :D
     
    Last edited: Apr 1, 2020
  33. michaelgrilo

    michaelgrilo

    Joined:
    Oct 15, 2018
    Posts:
    21
    I'm having an issue with the Base Camera Anchor component. The target offset only seems to work for the X value, not Y or Z. Any help would be appreciated.
     
  34. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Lol. Hope your character is not an orc.
     
    Tryz likes this.
  35. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey @Crossway,

    Check out the demo_3rd_Person_Style demo. On the ootii Camera Controller inspector, go to the "Advanced" view and enable the two transition motors:



    This will cause the "zoom over the shoulder" in my demo.

    This works because the "Targeting" motor uses a small 'x' axis offset from the anchor (which is the head).


    Depending on your setup, you can do the same thing. Of you may need to uncheck "Use Rig Anchor" and set a completely different "shoulder anchor" you want this motor to be based off of.

    Hopefully that makes sense.
     
    KeithBrown and TeagansDad like this.
  36. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I'm not sure why I only limited it to the 'x' axis, but I added the other two and this will be in the next update (not todays).

    Until then, you can add this code to BaseCameraAnchor.cs line 366:
    Code (CSharp):
    1. lNewAnchorPosition += ((_RotationRoot != null ? _RotationRoot.up : _Root.up) * _RootOffset.y);
    2. lNewAnchorPosition += ((_RotationRoot != null ? _RotationRoot.forward : _Root.forward) * _RootOffset.z);
    3.  
     
    KeithBrown and TeagansDad like this.
  37. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    No matter where anchor is set zooming always zoom to the center of that anchor. My character is close to camera and anchor needs to be somewhere around hips (Because I want to show character's shoes too) but when zooming I need camera to zoom around head/shoulder.
     
  38. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    That's correct. If you use the "field of view" zoom instead of a new motor (like I showed above), it will always go to the center of the anchor because you're not moving the camera... just changing the camera's FOV.







     
  39. SirTwistedStorm

    SirTwistedStorm

    Joined:
    Sep 20, 2015
    Posts:
    192
    What would be the best approach to use this in a multiplayer game? I ask because the documentation says "NEVER make the Camera Controller a child of the player".
     
  40. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    Only spawn a camera for the local player. Don't assume the "Player" tag is the local player, use actual logic to spawn and assign the camera to the local player.
     
    Tryz likes this.
  41. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hi. @malkere is correct. You would only have a camera on the "local player" and not on what Unity is now calling the "ghosts" that are other player computers.

    So, when your local character is instantiated for the player on their machine, you will probably need to use code to set the Camera Controller's "Anchor" and "Anchor Offset". Different networking solutions have different approaches to instantiating the local character. So, follow their setup.
     
    SirTwistedStorm likes this.
  42. vegasanx

    vegasanx

    Joined:
    Apr 7, 2019
    Posts:
    31
    Is there a way to have this camera controller still working when timeScale is 0?
     
  43. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I'm afraid not. Most all my logic uses DeltaTime. So, if that is 0 than the camera won't move.
     
  44. dinhvanvo1987

    dinhvanvo1987

    Joined:
    Aug 4, 2018
    Posts:
    4
    Camare Controller can working with PUN2??
     
  45. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    PUN2 is a networking package and has nothing to do with camera controllers. You can use Camera Controller with PUN2 the same as any other networking solution. You will of course have to setup logic to handle the camera for the local player only if you are spawning multiple players, as has been written about before in this thread already.
     
    Tryz likes this.
  46. dinhvanvo1987

    dinhvanvo1987

    Joined:
    Aug 4, 2018
    Posts:
    4
    You have example working with PUN2? I takes 2 days try to working with it.
     
  47. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    You're probably better asking in a PUN2 thread. A camera controller just handles the movement of a camera. Whether that's multiplayer or single player the controller doesn't care. Usually for multiplayer you are spawning multiple player objects on a client, only one of which you want a camera controller on (the local player) so there is some logic you need to add to your game, but other than that it's the same for any networking package. I use Mirror personally though.
    What's the problem you're having?
     
    Tryz likes this.
  48. dinhvanvo1987

    dinhvanvo1987

    Joined:
    Aug 4, 2018
    Posts:
    4
    I use tutorial here: https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/intro
    It have CameraWork Component for camera, i want use Camera Controller instead for CameraWork.

    In PlayerManager on Start method

    Code (CSharp):
    1. if (photonView.IsMine)
    2.             {
    3.                 CameraController lController = GameObject.Find("Camera Rig").GetComponent<CameraController>();
    4.                 lController.Anchor = this.transform;
    5.             }
    If single player it work, when new player join room all CameraController with property Anchor set to None (Transform).

    This is Image: https://ibb.co/RCWJHhy
     
  49. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Thanks @malkere . You rock and are exactly right in all your posts! Thank you. :)

    Hi @dinhvanvo1987 ,

    I would expect that.

    If you think about it, the Game Object that represents the character and even the Camera Controller probably doesn't exist until the network code creates them. That means you need to set the Anchor property after the network code has the player join the room (and creates the GameObjects).

    I wouldn't know that by default and you could be using any of a number of network solutions.

    The code to set the Anchor would be something like this:
    Code (CSharp):
    1. CameraController lController = gameObject.GetComponent<CameraController>();
    2. lController.Anchor = <networked gameObject>;
    You need to figure out where PUN2 lets you know the player objects have joined and been instantiated. Then, connect your new objects.
     
  50. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    Have you ever tried/had success clamping acceleration to reduce mouse spin during lag spikes?