Search Unity

Camera Controller Release

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

  1. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hi @malkere , the orbit speeds (yaw and pitch) are frame rate independent. So, lag spikes shouldn't effect them. However, you could see some popping on extremely slow frame rates.

    I did some tests and I'm not seeing acceleration issues. If you want to do a video and email it to tim@ootii.com, I'll look (typically on weekends) and see if there's something I can see.
     
  2. bavollee

    bavollee

    Joined:
    Jan 26, 2016
    Posts:
    17
    Hi, ootii team,
    Your product is nice and easy to use.
    But when I try to test the CameraController demos in my android phone, it is not what I expected. Does the input source could not support mobile phone by touch?
    For example, to zoom the camera view, I can use mouse scroll button to zoom up and down. But in mobile phone, I can't zoom the camera view by two fingers.
    For example, to rotate the camera view, I can use mouse right button to zoom up and down. But in mobile phone, I can't rotate with any finger operations.
    The demos only can run in Windows target?
    If I want to use in mobile phone with fingers operations, what should I do? Is there a setting for switch PC to Android or iOS.
     
  3. Tryz

    Tryz

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

    A quick start is to just change the "View Activation" parameter on the Unity Input Source to be "None". Now it will just work with any touch & drag on a mobile device.

    By default I'm using the Unity Input Source... that uses Unity's native Input Manager. So, you could edit Unity's Input Manager to reference the touch inputs you want. For example, update my "Camera Zoom" entry to use the mobile inputs however Unity's Input Manager does it.

    The best answer is really an Input Source that uses whatever input solution you use. Check out this post on Input Sources. In this case, you can customize your input source to read any kind of input; pinch, drag, tap, etc. Or, you can reference another input solution like Rewired or Easy Touch 5.

    I don't have a custom mobile input source out of the box. I just use Unity's native Input manager.
     
    bavollee likes this.
  4. bavollee

    bavollee

    Joined:
    Jan 26, 2016
    Posts:
    17
    Thank you for your answer. This answer is so helpful and warm. I'll take your tips. ^_^
     
    Tryz likes this.
  5. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    I'm having an issue where the camera is "pushing" the target forward. Basically, as soon as I start the scene the camera bumps into the player and pushes the player forward, then "follows" the player and pushes it again. I've gone through the documentation and have setup the controller as suggested. It seems like it has something to do with the collision system, if I turn off "Test Collisions" then it is fine, except that the physics of the player seem to stop working.

    Really confused here, and not familiar with your asset. Any ideas?
     
  6. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    If I had to guess, did you nest the Camera Rig in the character? If so, this would definitely happen.

    In the documentation, I mention not to nest the Camera Rig. That's because the character and camera have a circular relationship and you don't want them "pushing" each other.

    Check if that's the case. If so, disconnect them. I hope that helps.
     
  7. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    No, the rig is at the top of the hierarchy. I do have a rigid body and a sphere collider on the main camera for some physics and sound effect related stuff though, could that be it?
     
  8. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    That sounds likely. I would try putting the CameraController's GameObject on a layer that is excluded from collisions with the player's layer in Project Settings -> Physics -> Layer Collision Matrix.
     
    Tryz likes this.
  9. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    Yea, definitely was the sphere collider on the camera if anyone experiences this in the future.
     
  10. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    My player model uses root motion and has an animation that is a bit shaky (intentionally), which causes the anchor point to shift a bit while moving, which results in the camera bouncing side to side a little. Any ideas on how I can prevent the camera from doing this little wobble?
     
  11. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    This has something to do with using root motion. Going to look into my rig and animation keyframes and see if I can find a stable transform for the camera rig anchor.
     
    Last edited: Jun 18, 2020
  12. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    You could use a third object to follow your character and do smoothing that you want. Then, have the Camera Controller follow that. I include a "Base Camera Anchor" component for that kind of control.

    Check out these posts:
    Camera Anchor
    Base Camera Anchor
     
    TeagansDad likes this.
  13. bavollee

    bavollee

    Joined:
    Jan 26, 2016
    Posts:
    17
    Hi, Tryz, there are many compile errors when I build a windows standalone target. The follow errors just like:

    Assets\ootii\Editor\CameraController\CameraControllerEditor.cs(7,7): error CS0246: The type or namespace name 'UnityEditorInternal' could not be found (are you missing a using directive or an assembly reference?)

    Assets\ootii\Editor\Framework_v1\Utilities\Coroutines\EditorCoroutineExtensions.cs(17,70): error CS0246: The type or namespace name 'EditorWindow' could not be found (are you missing a using directive or an assembly reference?)

    Assets\ootii\Editor\CameraController\CameraControllerEditorSymbol.cs(6,3): error CS0246: The type or namespace name 'InitializeOnLoadAttribute' could not be found (are you missing a using directive or an assembly reference?)

    and so on. And I've tried to modify it many times, also search google many times.
    If you also encounter this problem, feel free to respond me and thank you very mush. Sorry to bother for such question.
     
  14. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Have you removed the ootii.Editor assembly definition file (.asmdef) or modified it in any way? Check its properties and make sure that it's set to the Editor platform only:

    upload_2020-6-18_14-25-9.png

    The errors that you are reporting are what you usually see when you run a build and there are references to UnityEditor classes in your runtime assemblies (Assembly-CSharp.dll is where everything is compiled to by default).

    There are a number of files in the ootii runtime code base that reference UnityEditor classes, but that code is contained within #if UNITY_EDITOR ... #endif directives, so when you're building for a standalone platform, the code will not be compiled.
     
    Tryz and bavollee like this.
  15. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    Probably going to drop root motion, even with an empty game object following behind applying a generous amount of smoothing on the wobble, the wobble is still a bit ugly for the player.

    In the meant
    Well, this did help quite a bit, but there is still enough of a wobble that we may decide to either drop root motion, change the animation, or just live with it.

    If we end up solving it I'll post a solution here for others if they might want it.
     
    Tryz likes this.
  16. bavollee

    bavollee

    Joined:
    Jan 26, 2016
    Posts:
    17
    Thanks very much, TeagansDad! Yep, it works. It's the "Assets\ootii\Editor\ootii.Editor.asmdef", I changed it so it came to the problem. I made it back and take some other stuffs.
    You guys are so friendly, and reply quickly. I'm thankful and best regards.
     
    Last edited: Jun 19, 2020
    Tryz and TeagansDad like this.
  17. Pollawat

    Pollawat

    Joined:
    Aug 27, 2016
    Posts:
    192
    Hello sir I have a question. I'm using the MOBA demo.



    As you can see here. How to prevent the camera from passing through the terrain or any object that has collider?

    Thank you.
     
  18. bavollee

    bavollee

    Joined:
    Jan 26, 2016
    Posts:
    17
    Do you enable the colliding function? You can editor it in inspector view, like the picture below:
    Snipaste_2020-06-28_10-45-29.jpg

    Make sure your terrian or ground's layer is the collision layer. The author provide us a convenient way to setup camera collision.
     
    Tryz likes this.
  19. bavollee

    bavollee

    Joined:
    Jan 26, 2016
    Posts:
    17
    Hi, ootii team, sorry to bother you~
    The UIBinding.cs is origin in project. I just import 'Camera Controller' to the exist project and do nothing.
    When I run the project again, it comes many werid problems. Such as the UIBinding.cs goes wrong:
    goes_wrongss.jpg
    It couldn't not find other nodes when the ootii folder is exist. But when I delete the ootii folder, the project is normal back.
    Does the Camera Controller modified sth or affect some code functions to my origin project? Like Scripting Define Symbols(Project Settings/Player) or somewhere?
    Best regards!
     

    Attached Files:

  20. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Yes; in the file CameraControllerEditorSymbol (under the "Editor" folder hierarchy), is an [InitializeOnLoad] class that sets the scripting define symbol OOTII_CC if it is not already set.

    Not sure why that would cause the problem you're experiencing though.
     
    bavollee likes this.
  21. bavollee

    bavollee

    Joined:
    Jan 26, 2016
    Posts:
    17
    OK, thanks for this reply. I'll keep going to debug and try to figure out this weird problem. I think it's my origin project's reason.
    If any update or solved way, I'll update here for share.^_^
     
    TeagansDad likes this.
  22. bavollee

    bavollee

    Joined:
    Jan 26, 2016
    Posts:
    17
    Hi, ootii team and TeagansDad, I had solved the problem. It's my origin script which will conflict with Text.cs("\Framework_v1\Code\Graphics\Text.cs"). I change the Text.cs to CCText, it seems be OK now.
    Thanks for attension.
     
    Tryz likes this.
  23. bavollee

    bavollee

    Joined:
    Jan 26, 2016
    Posts:
    17
    Hi, ootii team and the community friends, I followed the prompts you gave and tried several times. I had try the android target on my phone, but the input still not work. For clean test, I just try the demo from CC(ootii\_Demos\CameraController\Scenes\demo_3rd_Person_Style.unity).
    Question:
    In my windows PC, I can use mouse to drag the screen so that the camera can rotate with. And use the wheel button(middle mouse button) to Camera Zoom, and so on. But when I package the demo to an android apk and install in my phone, when I touch the screen, both one finger to drag or two finger to zoom are failed. The camera is chaotic when I touch the screen.
    Clean test:
    I just use the demo scene "demo_3rd_Person_Style.unity" for test. I had try the Input Source's view Activator's any state, it all failed.
    Does mobile device support require me to write other code or use the mobile touch extension?
    Confuse:
    I mean the demo is normal on the PC, and the input support on the mobile phone is not provided, right?
    You said that you didn’t use other plugin such as EasyTouch, and you used Unity’s origin input manager. How do you handle touch and zoom on android phone with unity input like you said in your demo?
    Sorry to bother this thread again. I have just studied unity for several weeks, and I'm very happy to learn from all of you.
    Thanks again!
    cc_input.jpg
     
  24. autumn_737

    autumn_737

    Joined:
    Jul 23, 2012
    Posts:
    19
    Hi bought camera Controller, loving it so far.
    What's the best way to go about doing 3rd person aiming, like with a bow and arror? I want to move closer to the character and focus on a point but retain movement with character.

    Regards,
    Josh
     
  25. bavollee

    bavollee

    Joined:
    Jan 26, 2016
    Posts:
    17
    You can use the Camera Motors with Targeting. With the right mouse button, you can Targeting In or Target Out.
    targeting.jpg
     
    Tryz likes this.
  26. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hi @bavollee ,

    I typically do support on the weekends. So, sorry for the delay. I'm glad @TeagansDad was able to help on the other stuff.

    For mobile devices, you may need to customize the Input Source. Because there's are lots of different input solutions and input devices (game pads, keyboards, tab screens, etc), I abstract the input solution. That means for things like zoom and rotations on a mobile device with no buttons you'll want to customize what activates the input and ramps the value.

    Please check out this post. It and the video should help:
    Input Sources

    For something like zoom, the Camera Controller uses the "Zoom Action Alias" property to zoom in & out. That means in your mobile input source, you'd return values like -0.1 or +0.1 for the "Zoom Action Alias". You could tie that to a pinch, a scroll bar, a dial, etc. In the end, you're just returning the value.

    Check out the post. If it still doesn't make sense, feel free to email tim@ootii.com.
     
    bavollee likes this.
  27. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hi @autumn_737 ,

    @bavollee is right. You'd use different "motors" to represent the different views. I use the setup he shows above to have my bow & arrow view be just over the shoulder. The transition motors move you between the different "views" with a button press.

    Check out the User's Guide. I talk about it on page 23.
     
  28. bavollee

    bavollee

    Joined:
    Jan 26, 2016
    Posts:
    17
    Yep, I've got your points. I need to implement the touch or zoom behaviour in my script or use third-party input, then implement the IInputSource interface.
    Thank you so much. Both you and @TeagansDad are warm-hearted.
    Best regards.
     
    Tryz likes this.
  29. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    Hi, in my game we have objects that the player can interact with. We want the user to "select" or "click" (whatever word you want to use) an object and have the camera transition to a fixed straight down view of the top of the object. I have transitions setup to let the player go in-and-out of this view, but I'm having a bit of a struggle getting it to work the way I would like. I've been debating between using your fixed motor and its API to handle the positioning of the camera motor relative to the object, but given that our objects can be different from one to the next I'm not getting the visual flow that we want.

    Is there a better motor I can use for this, where I could assign an offset for the camera and then specify a "target" anchor at runtime for the transition? Should I be looking at building a custom motor here instead?

    I should add, I "almost" have what I want with a transition with the fixed motor, but would like to create a smoother motion during the transition. Any suggestions welcome.
     
    Last edited: Jul 21, 2020
  30. Tryz

    Tryz

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

    I think I understand. For bouncing the camera between targets (especially if there's a lot of them), I typically use a separate Camera Anchor.

    Check out these posts and see if they help:
    Camera Anchor
    Base Camera Anchor
     
  31. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    So would I be just switching the anchor of the rig, or switching what the anchor is "following" ?
     
  32. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Have the Camera Controller follow the new game object (I'm calling that the Camera Anchor) instead of the character. In side the Camera Controller's inspector, you would set the "Anchor" property to this new game object.

    From the post I linked to above:




    Now, you can move this new game object around and attach it to any other object you want. You can do any kind of smoothing or control you need. So, this new game object would jump between the targets and the Camera Controller will just follow it.

    You don't have to use my "Base Camera Anchor" component I provide. It works, but it's just an example. You can move your new game object any way you want and the Camera Controller will follow.
     
    Willbkool_FPCS likes this.
  33. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Hi, my project is using unity's new input system and seems that many errors are popping up.
    Is it possible to add support for unity's new input system.
     
  34. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I'll look at it this weekend or the next.

    I'm surprised that errors are being generated since it would be a new system and the standard one still exists. I'm not sure why they would introduce something that would cause errors, but I'll check.

    [EDIT]
    I started playing with the new input system and it looks like it disables the default Unity Input Manager when the new input system is imported. Unfortunately, this may take me some time to work through.
     
    Last edited: Sep 27, 2020
  35. Hansol08

    Hansol08

    Joined:
    Jun 27, 2015
    Posts:
    2
    HI,my project want to control camera roation by half-screen on mobile.
    I have other plugins(Control-Freak-2) to create input zone.
    I need to modify (UnityEngine.Input) to (ControlFreak2.CF2Input) in UnityInputSource class ,
    but namespace not found.
     
  36. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hi @hansol423 ,

    Your best best is to create a new "ControlFreakInputSource.cs". You would put this in your root folder for your other custom scripts and inherit from UnityInputSource. Once you do that, you can override the functions to use ControlFreak code.

    I don't own Control Freak. So, I don't know the exact syntax, but it would be something like this:
    Code (CSharp):
    1. using com.ootii.Input;
    2. using ControlFreak2.CF2Input;
    3.  
    4. public class ControlFreakInputSource : UnityInputSource
    5. {
    6.     /// <summary>
    7.     /// Retrieves horizontal view movement from the the input
    8.     /// </summary>
    9.     public override float ViewX
    10.     {
    11.         get
    12.         {
    13.             if (!_IsEnabled) { return 0f; }
    14.             return CF2Input.SomeDragFunction();
    15.         }
    16.     }
    17.  
    18.     /// <summary>
    19.     /// Test if a specific action is pressed this frame.
    20.     /// </summary>
    21.     /// <param name="rAction">Action to test for</param>
    22.     /// <returns>Boolean that determines if the action just took place</returns>
    23.     public override bool IsJustPressed(string rAction)
    24.     {
    25.         if (!_IsEnabled) { return false; }
    26.         return CF2Input.SomeTestFunction(rAction);
    27.     }
    28. }
    This post and video should help:
    https://ootii.com/knowledge-base/input-sources/
     
    Hansol08 and TeagansDad like this.
  37. Hansol08

    Hansol08

    Joined:
    Jun 27, 2015
    Posts:
    2
    sorry for the delayed response,
    thanks your support!!.
    I saw your post. after that,I override MovementX and MovementY.
    it is work for me.

    Regards
    Hansol
     
  38. bjolet

    bjolet

    Joined:
    Jul 16, 2020
    Posts:
    6
    Just checking if this was ever resolved? I'm also seeing errors due to the new input system.
     
  39. PiterQ70

    PiterQ70

    Joined:
    Mar 3, 2015
    Posts:
    82
    Hi @Tryz after import CC to U2020.1 I have got three errors:

    Code (CSharp):
    1. Assets\ootii\Assets\MotionController\Code\Setup\Helpers\MotionPackSetupHelper.cs(114,38): error CS0120: An object reference is required for the non-static field, method, or property 'AssemblyHelper.FoundTypes'
    2.  
    3. Assets\ootii\Assets\MotionController\Code\Setup\Helpers\InputSetupHelper.cs(39,114): error CS0120: An object reference is required for the non-static field, method, or property 'AssemblyHelper.AssemblyInfo'
    4.  
    5. Assets\ootii\Assets\MotionController\Code\Setup\Helpers\CharacterSetupHelper.cs(309,97): error CS0120: An object reference is required for the non-static field, method, or property 'AssemblyHelper.AssemblyInfo'
    How can I fix it? Thanks
     
  40. ledshok

    ledshok

    Joined:
    Oct 28, 2012
    Posts:
    28
    Can someone explain why there are two 'Invert Pitch' options please?
    upload_2020-12-2_19-6-6.png
    What would typically be considered as inverted mouse controls (ie pull mouse back to look up) is only triggered when both values are unchecked.

    While as a dedicated inverted mouse player it's nice to finally get some recognition that it's actually everyone else who is technically playing 'inverted' :) I'm mainly interested in understanding why two options exist (and how they might differ).

    Thanks!
     
  41. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    I'd like a simple camera set-up that works like the original Tomb Raider games or Mario Sunshine, a nice third-person camera that lerps around smoothly in the direction you're moving, looks behind you if you're moving backwards, can be manually adjusted and springs back when released, targets that can be manually set and un-set by cinematics and doesn't clip through walls; pretty standard stuff.

    I tried third-person mode, and the camera just moves with the player, not rotating in the direction the player rotates, so I set it to "adventure mode" and that seemed to fix it (although I'm not 100% certain what adventure mode changes in advanced mode). Unfortunately, the camera only moves when a movement key is pressed, which I have never encountered in any game I've ever played before, it doesn't even lerp to a stop, it just ceases to move when any key is released, and starts moving into it's position when a key is pressed. This seems highly unconventional and I can't tell if it's because I've got it set-up wrong or if it's just a barebones example working strangely.

    I'm hoping the solution to having a basic third-person camera won't involve huge amounts of custom coding, which I don't mind doing for more specific features, but out-of-the-box it would be nice to have a simple camera that looks and faces in the player's direction like most other implementations I've seen. Is this possible?
     
  42. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
  43. Pandur1982

    Pandur1982

    Joined:
    Jun 16, 2015
    Posts:
    275
    Hello i have a Problem
    Code (CSharp):
    1. Assets\ootii\Assets\Framework_v1\Code\Input\UnityInputSystemSource.cs(4,19): error CS0234: The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
    that i became, i can not use the old input system in that project on that setting i use booth under project settings / Player. Can somebody help me?
     
  44. Elashe

    Elashe

    Joined:
    Nov 14, 2013
    Posts:
    1
    I had the same issue and did some digging around, found a knowledge base on the developer's site that fixed it for me.

    https://ootii.com/knowledge-base/unity-input-system/
     
    pango, Tryz and Pandur1982 like this.
  45. Pandur1982

    Pandur1982

    Joined:
    Jun 16, 2015
    Posts:
    275
  46. Recon03

    Recon03

    Joined:
    Aug 5, 2013
    Posts:
    845

    FYI., Tim, the asset link is no longer any good. I own CC. but for those that may not. This should be the new link: https://assetstore.unity.com/packages/tools/camera/camera-controller-13768
     
    Tryz likes this.
  47. Pandur1982

    Pandur1982

    Joined:
    Jun 16, 2015
    Posts:
    275
    Hello i have a other Question, i looking for Head Bobing in FPS. give it a script or something function for the FPS - Mode?
     
  48. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Unfortunately, the Camera Controller does not have a head-bobbing script. I'm sorry.
     
  49. Pandur1982

    Pandur1982

    Joined:
    Jun 16, 2015
    Posts:
    275
    Thx for your answer.
     
  50. Emphy

    Emphy

    Joined:
    Feb 7, 2014
    Posts:
    33
    Hey! Just wondering about the collision prevention, specifically in 3rd person. When I look at my scene view, the camera seems to 'ride' along object walls, whereas I would expect the radius parameter on the collision detection should actually prevent this? I can make it 0.5, 1, 5, it always just touches the objects it should not collide with. And you get this clipping artifact on the camera, which I wanted to prevent. And yes, the layer for my environment is set to 'Default' - else the collision would actually occur I think.


    upload_2021-1-14_11-10-47.png

    upload_2021-1-14_11-12-51.png

    Is this a bug or am I using it wrong, or is it even intended like this? I think maybe it has to do with the minimum distance to the anchor; if there is no space between the anchor and the object to fit the camera in with its radius, then maybe it's logical that the camera tries to ride the wall or even clips it if there is literally no space. If my character is further from the wall then there is no problem. It might just be a case of 'no better solution if you are too close'.

    Still, in the below case I would maybe expect the camera to move up or not go into the 'crack' between my character and the wall, even if I'm allowing it in the yaw/pitch settings. Now it clips my character and I would be able to see his brains.

    upload_2021-1-14_11-34-36.png

    upload_2021-1-14_11-35-12.png

    I could add Player to the collision layer mask but that just more weird results. It will want to prevent collision with my player and it will just do weird things where the character will disappear from sight even because it is behind the camera.

    Thanks!
     
    Last edited: Jan 14, 2021
    Rujash likes this.