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
    I'm actually using it right now with the mouse and everything seems fine.

    A couple of things to check:

    1. Make sure you don't have more than one transition activating at the same time. For example, are there multiple transitions using the Same Action Alias and Input Type?

    2. The default behavior is that when you release the press, the Target Out transition runs. Any chance your Input Source is reporting an immediate release?

    If you want to send me some screen shots of your motors, I can look to see if I see anything.

    The other thing you may want to do is put the UnityInputSource in and test with that. If the mouse works correctly, you'll know it's an issue with your custom input source.
     
  2. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    I can get it to happen with the right click/UnityInputSource too in a basic scene I've just setup. Same as the other thread: Shooter Style Motion Controller, 3rd Person Fixed, targeting enabled.

    Like I said, it's strange because I can right click/trigger and see Targeting In go to In Action in the editor and it just sits there for seconds before it goes to Targeting. If I let go of the right click/trigger before it goes to the Targeting motor, it goes back to Targeting Out. It seems to go bad faster and get slower(between Targeting In and Targeting) if you move around while right clicking.
     
  3. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Can you send me that project?

    I'm not seeing it happen here (moving didn't matter). So, I'd like to do it in your project and check out the setup.

    Just send a zip to tim@ootii.com.
     
  4. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    I made a video of the issue.
     
  5. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The reason you're having the issue is your Targeting In" motor and "Targeting Out" motor are pointing to a motor that is disabled:



    Change the "Start Index" on the Targeting In motor and "End Index" on the Targeting Out motor to "1" and it works correctly.
     
    Last edited: Feb 7, 2017
  6. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    That looks like a collision issue that the camera can't get out of.

    Do you have any colliders on the bike or the character that have a layer the camera is allowed collide with?

    If you just disable collisions for now, does it go away?

    Could you send me a small project with the issue happening? With something like this, I usually have to step through to see what is in the scene that's causing the issue.

    [EDIT]
    You really did use a lot of motors! :O

    I have the numbers in the next build. It looks like this:
    [0] 3rd Person Follow
    [1] Targeting
    [2] ....
     
  7. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    I get it now. It also explains why things broke so bad when I removed 3rd Person Follow. Thanks a lot!
     
    Tryz likes this.
  8. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Most of my work is in 3rd person and I haven't used a lot of 1st person controllers. UFPS was good, but it had a built in camera solution.

    The Camera Controller should work with any character controller, but I can see where a lot of 1st person controllers probably implement the camera themselves.

    The Motion Controller (one of my assets) is primarily a 3rd person controller, but it is capable of doing 1st person as well. You simply have to provide a 1st person ready character (ie no head).

    Unfortunately, that probably doesn't help much. :(
     
  9. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    I'm a bit confused what the differences between Is Collision Enabled and Collision Properties Is Colliding Enabled are. But I had Is Collision Enabled disabled already and disabling Is Colliding Enabled doesn't fix the issue. I also tried turning off everything in the scene to see if it would fix itself during runtime but it keeps flipping around.
     
  10. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    As far as sending a small project I could probably do so tomorrow but it's pretty difficult to do so with how many moving parts there are in this game.
     
  11. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The main collision properties are on the CC itself in the "Collision Properties" section. If you disable collision there, it's disabled for the whole camera.

    Some motors have a separate "Is Colliding Enabled" property that is only used when that specific motor is active. It's a way of disabling collisions for just that motor.

    I can't reproduce the issue here. So, I need to see how the camera is setup. In your case, my gut says it's something with the environment too.
     
  12. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    Sent the error demo to you
     
  13. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Got it. Give me a day and I'll let you know that I find.
     
  14. jessejarvis

    jessejarvis

    Joined:
    Aug 9, 2013
    Posts:
    303
    Hello! This is a great camera system, I am currently using it in all of my projects :)

    I'm loving it so far, but I have an issue with Mobile controls.

    Is there any way to set this so that on mobile it rotates the camera with the second mobile press instead? Currently touch controls rotate it constantly instead of when the second touch control is activated. Also when rotating on mobile the camera jumps to a specific direction as soon as the player starts to rotate.

    Thanks!
     
  15. Tryz

    Tryz

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

    Thanks for that. :)

    It really comes down to the input source you're using. With mobile and multi-presses, you want to customize your own input source and overwrite functions like IsViewingActivate() and ViewX, ViewY, etc.

    For example, if you open the UnityInputSource.cs file, you'll see that IsViewingActivate() is based on different mouse buttons and what you've set in the inspector. In your mobile input source, you'll change that code to return true only when there are two presses. You can use any input solution you want, just put the code here.

    Now, anything that uses your input source will only use ViewX and ViewY when two presses exist.

    Same with the values for ViewX and ViewY. In the UnityInputSource.cs, you'll see they come from the mouse or right Xbox stick. You need to override those to come from your mobile input solution... however you want.

    The nice thing is that all my assets can use the input source you create. So, create it once and use it everywhere.

    I hope that all makes sense.
     
  16. jessejarvis

    jessejarvis

    Joined:
    Aug 9, 2013
    Posts:
    303
    Thanks Tryz,

    I made two functions (mobileRotX and mobileRotY) which return the value of a touch input. Then I did:

    #if UNITY_ANDROID || UNITY_IOS
    return mobileRotX();
    #else
    return lValue;
    #endif

    in ViewX and ViewY respectively.

    Just building now to test. Thank you.
     
    Arkade and Tryz like this.
  17. AlexBuchnoff

    AlexBuchnoff

    Joined:
    Mar 7, 2013
    Posts:
    2
    HI, I am running into an issue. Ootii is overriding my character I am adding it too. I followed the pdf steps. That is not working though. I add ootii, click on the 3rd person style button, and it will give me a, "There is no camera error" I add the camera it will do one of two things, either duplicate the character and camera, or work but shut off the character controller.

    There was an issue of the ootii controller was causing the character to either "Bounce" into the air, get thrown in around in a never ending circle (with the camera), or forced through the map. That I managed to fix by simply shutting off the "Test Collision" button.

    So I tried a to look through the forums on this issue, but couldn't find one, unless I missed it. Looking for help to make it work. Oh, as for the controller, I am using Unity standard one, if that helps. Oh, the most current beta/collaboration.
     
  18. Tryz

    Tryz

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

    When you say "... my character I am adding it too", do you mean you are actually adding the Camera Controller to your character?

    If so, I can see where the CC would try to control your character... because it thinks its a camera.

    As I mention in the User's Guide (page 8), you never want to add the CC as a child of your character.
    http://www.ootii.com/Unity/CameraController/CCUsersGuide.pdf

    If you follow the steps in the guide (page 3), everything should be fine. There are a lot of people using it. So, I'm sure it's just a setup issue.

    If you're confident you set things up per the documentation, feel free to email me a picture of your hierarchy and CC settings (tim@ootii.com). That may help.
     
  19. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    Is there a way to make the look at camera follow more smoothly? I would like to adjust the speed it updates to a new position.
     
  20. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The Look At camera is typically anchored to something (like the Camera Controller's Anchor). Then when that anchor moves, it would move. So, the smoothness is determined by the anchor's movement.

    Are you using it like that or are you using it without an Anchor?
     
  21. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    So i'm setting up a combat targeting camera and the lookat works really well for this when I put the anchor on a gameobject that follows the player and the lookat on the gameobject I'm targeting. Really the only issue I'm having is when an enemy gets too close and the camera flips to the opposite side then back quickly if the enemy moves back to the opposite side of the player. Was just wondering if there was some smoothing somewhere but it sounds like it would be better for me to tween between the locations on the anchor.
    Does that sound right?
     
  22. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Exactly. The problem is that as soon as I start lerping and smoothing, it won't be where the anchor is. Better the anchor do that.
     
  23. Sarun_Ratta

    Sarun_Ratta

    Joined:
    Mar 26, 2015
    Posts:
    8
    Hi, I am looking at your product and it look very interesting, however I would like to know that Camera Controller support target system or not.

    Example of target system
     
  24. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The camera doesn't have a "lock-on" system as your video shows, but I have a couple of functions you can use to control the camera direction:

    CameraController.SetTargetForward(Vector3 rDirection);
    CameraController.SetTargetYawPitch(float rYaw, float rPitch);

    With these, you can force the camera to look at a specific target. You just have to determine the target and call the functions.
     
  25. Phesant33

    Phesant33

    Joined:
    Nov 13, 2015
    Posts:
    34
    Hi is there a relatively easy solution to the ORK spawning issue yet (setting an anchor that is not yet instantized)? I've tried adding the block of code suggested above to the Camera Controller script, but no luck.

    Would really like to be able to use this great controller.

    Thanks for any help
     
  26. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    On the CC side, it's just a matter of setting the Anchor property when the character finally exists:

    Code (CSharp):
    1. CameraController lRig = Component.FindObjectOfType<CameraController>();
    2. lRig.Anchor = XXXX;
    The challenge is that I don't know when ORK creates the character. So, you would need to add some code that grabs the ORK character transform when it finally does and set the Anchor.

    I'm not sure where/when you would place that code. That may be a better question for the ORK guys.
     
  27. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Are you using Motion Controller as well? If you leave the anchor field on the CC empty and have "Find" checked on the MC, then you shouldn't need to do anything else.

    You can also put a script on the CC that runs a coroutine in its Start() method. In the coroutine keep calling ORK.Game.GetPlayer() until it stops returning null.
     
    Tryz likes this.
  28. Tryz

    Tryz

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

    It looks like your post may have been deleted too.

    The Radius is working for me. I can see the setup change in debug mode.

    I've updated documentation to talk about how collision works and how to enable the debug info (page 6 & 7):
    http://www.ootii.com/Unity/CameraController/CCUsersGuide.pdf

    I hope this helps. Please let me know if you see something different.
     
  29. Jick87

    Jick87

    Joined:
    Oct 21, 2015
    Posts:
    124
    Thanks so much! That image on page 7 really helped me figure out the issue. I needed to scale down the radius value a lot more and then it worked great.

    Thanks! :)
     
    Tryz likes this.
  30. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    hi there ive been looking up and down the asset store, asking around, googling, etc

    I've been pointed towards ur third person motion controller, and i also noticed ur camera controller.

    I don't understand exactly what does camera controller have that third person motion controller doesn't have?

    obviously the third person motion controller has some kind of camera functionality, what incentive is that to purchase the camera controller?


    i apologize for my ignorance, i'm used to creating 2D games, and 3D character animation is a new dimension for me :)
     
  31. Tryz

    Tryz

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

    The Motion Controller is a character controller that controls the character. Think animation, movement, collisions, etc. It includes two simple camera rigs; one that follows and one that orbits. These cameras rigs work well, but don't have advanced features.

    The Camera Controller controls the camera. It's an advanced camera rig that supports multiple motors for different behaviors, obstruction detection, zooming, transitions, offsets, shakes, etc.

    I hope that helps.
     
  32. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    thanks for clarifying.

    Can i cleanly use the first person setting of camera controller to turn the third person motion controller into first person?
     
  33. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    also another question, lets say i choose to create 3rd person game.

    im potentially interested in creating a parkour type game, using the animations of this asset:
    https://www.assetstore.unity3d.com/en/#!/content/67802
    I've read that it comes with a completed animator with states and substates and all that good stuff and to transition from animation to animation u just have to call the necessary parameters, but it doesn't come with a controller, its just animations.

    I saw in your third person motion controller video that you have a preset type structure, u select in inspector the kind of driver fpr character and that affects played animations and there's various settings to fine tune.

    It shouldn't be too difficult to integrate your controller with the animation of the above asset right? i just have to create a driver of the controller using ur system?

    then for triggering actual parkour stuff, that's up to me to create the logic through scripting to interact with level geometry and trigger the animation parameters.
     
  34. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    also sorry one final unrelated questions:
    im thinking buying ur Dispatcher asset.
    I've read though that sendmessage is slow.
    whats the performance like compared to cached references in code?

    Or is registering listeners create a reference upon setting up a listener?


    EDIT::
    oh never mind saw web demo,
    how is it even possible for message system to be faster than direct function call!?!? lol
     
  35. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Yes, but your model will need to support 1st person. Sometimes you can get away with just placing the camera at the head, but sometimes the hair, mouth, and eyeballs can get in the way.

    I love his video.

    You can definitely do it with the MC, but "shouldn't be too difficult" is relative... especially when you think of the environmental conditions and level geometry. For example, knowing where the bar is to flip around or the wall to run up.

    You'll need new motions that transition from one to the other. With something like parkour, I wouldn't go into it thinking it would be easy. You'll have a lot of non-MC things to sync with... meaning the level geometry.

    How comfortable you are with programming will play a part in that as well.

    I've not seen that. 95 ratings with an average of 5 stars is usually a good sign. ;)

    As an example, sending 500 messages with the web demo just now:
    Unity's native SendMessage = 5.83 milliseconds
    Event Dispatcher = 1.52 milliseconds

    Registering listeners creates the reference.
     
    TeagansDad likes this.
  36. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Unity's native SendMessage probably still has to find the GameObjects to send the message to. They may even send it to a lot of GameObjects.

    I'm using a nested cache to sort the listeners. So, there's two fast look-ups to get to the exact recipient.

    In my test, calling the function directly through a reference (ie no messages) = 0.3 milliseconds. Having a direct reference and calling the function will always be faster.
     
    luniac and TeagansDad like this.
  37. Mantra-Games

    Mantra-Games

    Joined:
    Nov 27, 2012
    Posts:
    169
    Hi, I'm looking to pick up a cinematic controller to replace pro camera 2D for a 2.5D 3D game. I'm also running Opsive 3rd person controller. Does your spline path feature work to follow the player controller? If so can you move the camera on any axis on the nodes when doing so? Finally does it have trigger zones for switching cameras?

    Thanks.
     
  38. Tryz

    Tryz

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

    The Spline Motor will follow the spline that is set. The spline tool I created is pretty basic, but if that spline were a child of the player the camera would follow it.

    I'm not sure I fully understand the question. The spline is a 3D path and the camera will follow the path. During the movement, the camera will rotate to focus on the target.

    The camera has multiple motors and you can transition between motors with a single function call. The asset itself doesn't have a trigger or zone system. Instead, you'd just setup a typical trigger volume in Unity and when the camera enters or leaves, you'd call the function as needed.

    You can use this function call in response to triggers, collisions, events, etc.

    I hope that helps.
     
  39. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    Hi
    Please could you add namespace to all Editors' use of "CameraController" ?
    I already have a "CameraController" in the global namespace.
    In some places it caused an obvious error. In some I just wasn't getting custom editors.
    Thx

    p.s. EDIT: I did write something about CameraControllerInspector but now I realize that's from RootMotion. I'm still no longer seeing your custom inspector but now fear it's something to do with applying MCTO asset to your CameraController and it confusing Assembly use somehow. I'll investigate further. Hopefully it'll result in a tiny patch I can offer asking for a tweak to how some type is detected (that's been the case previously). Any thoughts obviously most welcome!
     
    Last edited: May 15, 2017
  40. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I'm usually the one telling people to use namespaces. :)

    I'll make sure they exist in the editor for this week's push.

    Unfortunately, I don't know anything about MCTO. I don't use assemblies with the CC as it's all code. So, I wouldn't expect there to be any confusion.
     
  41. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    I apologise for wasting your time -- that CameraControllerInspector from RootMotion was the culprit!
    I'd excluded from package import, the directory "Shared Demo Assets" but hadn't spotted "Editor/Shared Demo Scripts". The latter had the aforementioned file whereas the prior had a "CameraController.cs". doh.
    Deleted and all is right with the world again! Sorry again.

    Though since I'm writing, maybe you might answer a naiive question. Naiive since I haven't begun investigating yet so feel free to say "RTFineM" and I will happily proceed ;-)

    My environment has some narrow stairways with high walled colliders (albeit seemingly transparent). I'd like to encourage the camera to reposition itself above / behind the player in these situations. I anticipate investigating how to create some extra camera motor which I'd enable when I detect this situation? (Despite evidence to the contrary in this thread, I'm usually a competent programmer ;-) ) Thanks for any tips or direction!
     
  42. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    hahaha... NP :)

    For tight spaces, I typically use a motor that is closer to the character by having a motor with a smaller 'Distance'. Then, I use trigger volumes and some small code that will set the active motor on the CC when the trigger is entered.

    Once you create the trigger, you would just use code like this:
    Code (CSharp):
    1. CameraController lCC = gameObject.GetComponent<CameraController>();
    2. lCC.ActivateMotor(2);
     
  43. Jick87

    Jick87

    Joined:
    Oct 21, 2015
    Posts:
    124
    Had a quick question...

    Are there any callbacks or similar for when the camera will fade the character mesh? Like perhaps one that fires when the character needs to fade just before it starts to fade? And one after the fade is complete? Or something along those lines?

    I didn't see anything about it in the documentation, but I could have missed it I suppose.

    Thanks.
     
  44. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I don't have any for when the meshes are faded, but I do have:

    MotorActivated
    MotorUpdated
    MotorDeactivated

    I can add 'FadeInCompleted' and 'FadeOutCompleted', but it will take me a week or two to get to it as I'm buried. I would add this in the UpdateFade() function of the CameraController.cs. That function is what ramps the fade in and out.
     
  45. Jick87

    Jick87

    Joined:
    Oct 21, 2015
    Posts:
    124
    Thanks for the reply!

    Yeah, I'll see what I can figure out.

    Basically what I wanted it for is to change the "Rendering Mode" on my player's mesh shader from "Opaque" to "Transparent" or "Fade" right before the fade out happens and then set it back to "Opaque" after it is done fading back in. Seems like that would be a good way to handle the fading without needing to have the player set as transparent all the time, which has issues with proper lighting and such.

    Is there something similar built in already and I just missed it?

    Thanks.
     
  46. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    There's nothing already built in for that, but it's a great idea.

    We'll have to see if there's a way to change that on the material at run-time. It may be simple... I just haven't looked.
     
  47. Jick87

    Jick87

    Joined:
    Oct 21, 2015
    Posts:
    124
    Yeah, I did a little bit of research on it before I posted. One interesting thread I found was this: https://forum.unity3d.com/threads/access-rendering-mode-var-on-standard-shader-via-scripting.287002/

    Based on that it seems you need to set a little more than just the mode in order for it to work, but it does seem possible.

    One other interesting note in that thread is that you need to make sure you have a material that is using that somewhere in your project so that Unity will compile your executable with the proper shader variants, but that isn't a huge deal.

    Maybe that thread could be useful to you too if you decide to implement something like it in the asset. :)

    Thanks.
     
  48. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    This is good... thank you. It's added to my to-do list, but my list is pretty long. :)

    I do like the idea of auto-setting it if we can. I think that's smart.
     
  49. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    Looking for a little guidance-

    I'm trying to use Camera Controller to create a camera with similar behavior to Resident Evil 4/5/6- specifically how the camera always stays behind the player as they rotate- I'm not sure if this is a camera or character controller issue or both?

    Example video from RE5


    I've tried using all the motors to recreate it but I'm unable to do so- any tips on what to focus on? I'm using Camera Controller with my own player controller- Thank you.
     
  50. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    You can use the Fixed Motor and set the Anchor Offset to something like (0, 2, -3). That will always keep the camera behind the player even as they rotate.

    You can also use the 3rd Person Fixed motor and check the "Rotate With Anchor" option. That will also keep the camera behind the player as they rotate.
     
    imaginationrabbit likes this.