Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Deprecated] Simple RPG Camera

Discussion in 'Assets and Asset Store' started by Ninjaxim, Oct 2, 2013.

  1. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    I haven't played either of those games, but yes that's the idea! There is always room for improvement too, so if you find anything wrong or lacking with it let me know!

    I just realized I didn't make a demo showcasing it, so I will do that in the near future.
     
  2. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Great! I've had my eye on this camera for a while, but I wasn't quite at the point where I needed more than a basic camera setup. I'll be picking this one up tonight or tomorrow. Thanks!
     
  3. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Awesome! Thanks for your support and be sure to let me know if you need anything.
     
  4. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    @Ninjaxim, this works great! Thank you! I've had trouble finding a camera asset that adjusts to terrain (when scrolling/panning over terrain) and also checks for collisions when rotating.

    I do have a couple of small feature requests for you...

    I would like the player to be easily able to switch between having the camera follow the player and being able to scroll/pan around the scene. So the camera would follow the character until the player starts dragging or scrolling the camera, at which point it would stay in "movement" mode until the player hits a key to lock it to the player again.

    So on the Movement tab, there could be toggles under Allow Mouse Drag, Allow Edge Movement, and Allow Keys that would have the corresponding type of user-initiated camera movement break the lock on the target. A single keypress (that doesn't have to be held) would lock the camera to the target again.

    The other request is: is it possible to limit the camera bounds relative to the target? I can set the current limit bounds so that the camera cannot be scrolled beyond what I have actually built in my scene, but it would also be helpful to be able to allow the player to scroll around the area near his current location without letting him scroll around the entire scene.

    Well, the first one is pretty small. :) I'd do it myself, but I like to keep the process of updating my third party assets simple.
     
    kurotatsu likes this.
  5. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    @TeagansDad

    Glad to hear you are liking it!

    I've added your feature requests. Since updating the package on the Asset Store can take some time, you can download the updated package on my website here (after logging in and registering your invoice number).

    I don't usually submit updates to the store until they have been confirmed as tested by the client who requested them.

    Let me know if I added your features correctly!

    I also fixed a minor bug with the scene not being set as "dirty", so now making changes on the inspector should allow you to save those changes on the scene.
     
  6. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    @Ninjaxim

    Wow, that was quick!

    I gave it a test and now it's pretty much perfect! Thank you!
     
  7. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Hi @Ninjaxim,

    Perhaps I spoke too soon... I'm getting some visual artifacts on my terrain that I only get with this particular camera asset. It doesn't do it on perfectly flat terrain, but it does it anywhere the height has been raised. The problem occurs in a completely new project as well.

    Everything looks fine when the camera isn't moving, but as soon as it starts rotating, scrolling, or following the player, I get these weird shadowy blobs shimmering on my terrain:





    In these particular screenshots, I tried it out in your RPG Demo scene, as I wasn't seeing it on the terrain that you used in the demo. I hid your terrain and then quickly stamped out a new terrain using Gaia. I started seeing it happen immediately when I ran the game (it didn't do it when the terrain was flat).

    Now here's the weird part. In the new project (as well as in my own), I had it set to Deferred Rendering and Linear Color Space. I was able to make the issue go away in the new project by setting those values back to Forward Render and Gamma Color Space, and when I changed them back to Deferred and Linear, the issue did not come back. In my game project, it was still there when I switched it to Forward/Gamma.

    I've got a couple of other camera assets, and neither one of them do this when moving or rotating the camera. But I want to use Simple RPG Camera, as it has all of the features that I want. :)

    Any insight into why it might be doing this?

    Also, I think you should double-check the "dirty scene" bug, as with the updated version you posted for me, when I make changes to the SRPG Camera component in the inspector when the game is not running in the editor, the settings usually revert to what they were before when I press Play. The only way that I can make it keeps its settings is to update the camera prefab that I have it attached to. It doesn't do this for me in the most recent public version.
     
  8. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    @TeagansDad

    I'll have a look, thanks for the detailed explanation!

    What version of Unity are you using?
     
  9. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    @Ninjaxim,

    I've got 5.3.2p1 on one computer and 5.3.1f1 on the other. It does it on both.

    I checked one other thing: your terrain in the demo does not have normal maps set for the textures, so I removed the normal maps from my terrain. Didn't make any difference.

    The only additional thing in the new tester project is Gaia, but it doesn't do anything out of the ordinary with Unity's terrain. And in this example, all that it did was shape the terrain with a heightmap and apply one texture to it.

    Thanks for taking a look!
     
  10. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    @TeagansDad,

    I think the blobby shadow issue is related to the camera's Near Clipping Plane. Larger terrains don't seem to like very small clipping plane values. I found a small bug with my collision clipping feature that forces it to a value when that feature is turned off, which should not happen.

    I think I also fixed the dirty scene stuff.

    You can download the fix on my site (v2.4.1c). Let me know if that solves the issues! If not, I'll keep working on it.
     
  11. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    @Ninjaxim,

    That did the trick! The blobby artifacts are gone. It's not a particularly large terrain (256x256).

    But now ALL of the shadows in the scene disappear if I rotate the camera left or right (I can rotate up or down and they stay there). And once they're gone, they're gone for good -- most of the time. Once in a while they'll appear again for a moment, but they'll be pixelated-looking smudges.

    Just in case your day was boring. ;-)
     
  12. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    @TeagansDad,

    Strange, you're sure it isn't anything to do with your lighting / rendering settings? Your other camera assets work fine? Have you tried adjusting the near clipping plane on the camera?

    Perhaps you could send me an example project with the issues.
     
  13. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    @Ninjaxim,

    I did try adjusting the near clipping plane, and I've tried using just the basic Directional light in the scene without changing any of the lighting settings. And my other camera assets do work fine. :)

    I'll put together an example project that demonstrates the issue. Thanks for taking the time to look into this!
     
  14. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    @Ninjaxim,

    And wouldn't you know it... I can't seem to replicate the problem in a new project. It works fantastically after I add Tenkoku dynamic lighting back in plus a stack of several image effects on the camera.

    May be time to clear out the cruft in my game project and start importing the assets into a clean project anyway. Thanks for your help, and if the problem shows up again I'll let you know.
     
  15. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    @TeagansDad,

    Ah, well that's good to hear! You're welcome, always happy to help! I'll be here if you need me.
     
  16. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Greetings Ninja. I have had your camera script in our live game for about 4 months now and a request keeps coming up - thought I would pass it on in case you think its good. I have my camera set to Third Person (we are sandbox RPG) with auto follow. Its great. However, It's nice too how we have it set so that you can pan the camera around to the front of the character so you can see them. We do a lot of building in our game. People complain that they want the auto follow feature, but they also want to be able to move their camera around, while standing still, and it not return until they move again (for example when people want to take a screen shot of their character standing in front of their house, they cant because as soon as they let go of the mouse button the camera whips back around behind them). Would it be possible to add this as an option to check - only return on player move, as an option for auto follow mode? Thanks for listening and your support and great product!
     
  17. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    @Tethys,

    How do your players move around? If it's via key press, I can upgrade the current "On Key Press" feature into a list of keys for staying behind the target / returning to origin settings instead of just a single key. That way you can set any number of keys that will trigger the code to rotate the camera back to where it needs to be.

    If your players move without key presses, you might be better off just adding some code to your player controller script that toggles the return bool on the camera on/off.

    Edit:
    I went ahead and updated the key press features, so they are now a list of keys instead of just a single key. It can be downloaded on my site (v2.4.2c)
     
    Last edited: Mar 14, 2016
    Tethys likes this.
  18. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    733
    HI Ninjaxim,
    i found a little issue after enabling "Allow mouse drag" when the y of the items is far away from zero:
    Example:
    - add a plane (at 0,10,0) and a sphere (at 0,11,0)
    - set the sphere as a target
    - enable "Allow mouse drag"
    - play ... the camera don't take in consideration the target y
    Cheers
    Max
     
  19. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    @sjm tech,

    Yeah, since movement doesn't really have a target to follow (unless it's locked to the target) it will default to a Y position of 'movementHitDistance' (default is 1).

    There's a new feature I added in v2.4.0 which allows you to enable collision for the movement settings, which will make it follow the ground height (or whatever it collides with) as you move the camera around. Just set the layers you want it to collide with on the Movement Collision Layers option in the Movement Settings tab and it should raise / lower the Y position according to whatever it collides with.

    If that doesn't work well enough for you, let me know and we can work something out for your case.
     
  20. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    733
    I'm thinking a scenario when i'm following my target and if i break the following to start dragging could be natural dragging from the last target position.
    I point this because other axes work in this way (x,z)...only y goes to 1.

    Yes, i saw the new Movement Collision ad is very useful but i think that needs a smoothing feature to avoid drastic vertical reposition...something like "soft tracking"
    Thanks
    Max
     
    Last edited: Mar 17, 2016
  21. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    733
    I found the cause of my issue ... is due by "movementHitBuffer" which is enabled by "Highpoit Detection" ... an hidden option when "Movement Collision Layers" is set to "nothing".
    I added "enableMovementCollisions" boolean to exclude collision detection if is not needed.
     
  22. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Ah, yes I can see what you mean. I will fix this in the next update.

    Thanks!
     
  23. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Version 2.5.0a is now available for download on my site. Not sending it to Unity quite yet, but will do so sometime next week probably.

    Along with some other fixes and improvements, I updated the demo GUI to use the new 4.6 uGUI stuff, so it's a bit better now.

    @sjm tech - It has the fix for your movement issue, would be cool if you could confirm that it's fixed!
     
  24. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    733
    wow...super fast as usual.
    All my issues are fixed...thanks!
    The new collision smoothing is awesome.
    Cheers
    Max
     
  25. Uto

    Uto

    Joined:
    Nov 10, 2014
    Posts:
    17
    Hello! This is a great asset! One question, is it possible to make a default set camera angle, so that when you rotate camera, rotation happens only on key/button down, and when you release it, camera view returns smoothly to the default angle?
     
  26. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    @Uto,

    Yup! In the Rotation tab, the Origin Rotation is the default camera angle. If you enable Return To Origin the camera will return to that angle you set whenever the user is not controlling it. Disable Allow Rotation if you don't want the user to rotate the camera with the mouse, and enable Allow Rotation Keys to allow the user to rotate the camera with key presses.
     
  27. Uto

    Uto

    Joined:
    Nov 10, 2014
    Posts:
    17
    Thanks and yes, it works! Is it possible to limit the rotation angle for left/right look, like you can with up/down? Currently I am using camera as top down with fixed camera, like in Diablo. So I would like to add left/right rotation but limit it for 180 degrees.
     
  28. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    It is now! I just added your request, you can download it on my website here (after logging in and registering your invoice #). It works by enabling the new Limit X Angle option and setting your desired min / max values in the Rotation tab.
     
  29. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    @Ninjaxim, that issue I was having with the shadowy blotches on my terrain has resurfaced. It shows up when I add the Distingo terrain shader to my terrain. Distingo allows you to change the UV scaling for both near and far in order to reduce tiling. The problem goes away if I remove or disable Distingo.

    However, I would like to continue using it, and I still don't encounter the problem with any other camera assets.

    Does that give you any idea as to what might be different on Simple RPG Camera?

    EDIT: I'm almost certain that this was the cause all along, but I was focused on what components were on my camera and how the lighting was set up.
     
    Last edited: Mar 24, 2016
  30. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    @TeagansDad,

    Is it something similar to the problem shown in this post? http://forum.unity3d.com/threads/shadow-artifact-problem-bug-on-terrain-solution.81499/#post-2536156

    I can easily replicate that issue in an empty project without my package (or any others) being imported at all (using Unity 5.3.4).

    Sounds strange that it'd only be an issue with my camera package and not others. My script doesn't do anything other than change the camera's position and rotation really. One setting on Simple RPG Camera does mess with the Camera component clipping values, but only while enabled (and I added it as kind of a work-around for that very issue).
     
  31. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    733
    Hi Ninja,
    in this video of my last project i would show how good and fast is Simple RPG Camera also for 3d object visualization on touch devices.
    Great asset.
     
    Last edited: May 25, 2016
  32. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    @sjm tech,

    Looking good, thanks for sharing! Would you mind if I placed it on the first post of this thread as an example of mobile use?
     
  33. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    733
    Yes, sure i'm pleased.
     
  34. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Thanks!
     
  35. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Version 2.5.0 is now awaiting approval from Unity. As always, registered users on my website can download the new version without waiting!

    Changelog:
    • Upgraded the old OnGUI Demo script to use the new Unity 4.6 GUI EventSystem
    • Updated the RTS Demo scene to demonstrate movement collision
    • NEW: SrpgcNavmeshAgentController.cs
    • NEW: Navmesh Demo Scene
    • SimpleRpgCamera.cs:
      • Helper Functions:
        • NEW: AddSecondaryTarget(Transform newTarget)
        • NEW: RemoveSecondaryTarget(Transform targetToRemove)
      • Target Settings:
        • NEW: Double Click Sets Target
        • NEW: Double Click Layers
        • NEW: Double Click Delay
        • NEW: Lock On New Target
        • NEW: Audio Listener At Focal Point
        • NEW: Secondary Targets
        • NEW: Focus On All Targets
      • Movement Settings:
        • NEW: Allow Double Click
        • NEW: Double Click Layers
        • NEW: Double Click Delay
        • NEW: Collision Smoothing
        • NEW: Collision Smoothing Speed
        • FIX: Highpoint Detection no longer does anything while collision is disabled
        • NEW: Show Collision Debug Lines
        • NEW: Movement Smoothing
        • NEW: Movement Smooth Speed
      • Rotation Settings:
        • NEW: Timeout Rotation
        • NEW: Timeout Rotation Delay
        • NEW: Timeout Rotation Speed
        • FIX: Stay Behind Target - On Key Press feature has been upgraded to a list of keys instead of just one single key
        • FIX: Return To Origin - On Key Press feature has been upgraded to a list of keys instead of just one single key
        • NEW: Limit X Angle
        • NEW: Min X Angle
        • NEW: Max X Angle
      • Fade Settings:
        • FIX: Added a check for material's _Color property
      • Mobile Movement Settings:
        • NEW: Break Target Lock
      • Mobile Zoom Settings:
        • FIX: Improved code to make mobile zoom feel a bit better
        • NEW: Auto Adjust Speed
        • NEW: Min Zoom Speed
        • NEW: Max Zoom Speed
        • REM: Zoom Deadzone
     
    sjm-tech likes this.
  36. Stankiem

    Stankiem

    Joined:
    Dec 4, 2013
    Posts:
    115
    I am moving the camera through script. If I have SimpleRPGCamera component enabled it doesn't move at all. If I disable it for the duration of the move and then try to re-enable it, the position goes back to the original camera position. How can I move the camera via scripting and bypass SimpleRPG Camera for some camera transitions etc...?
     
  37. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    You can set the camera's target to null, which then allows the camera to be moved around without disabling the component. Setting the camera's Controllable value to false prevents the user from controlling it as well. You can also modify the camera's CurrentRotation value (degree angle) to rotate / position the camera around a target via scripting.

    Would it be helpful if I added some way to set the target and try to keep the camera's current position?
     
  38. LadyAth

    LadyAth

    Joined:
    Jan 17, 2014
    Posts:
    158
    Really love the camera and all the settings, but I have a small request that I hope is possible?

    In my current project, I have the target offset defined to give a 3rd person over the shoulder view and it works great - except that in my game, the player character grows in size. What starts off as a great perspective ends up as being completely blocked when the model fills up the entire camera view. I got around this previously by creating different prefabs for the size 'stages', but now switching to runtime scaling instead. Is it possible to have the camera use a specific gameobject to create the offset from (eg. an empty gameobject above the mode's head or something) or to anchor to? Or would it be better to define the target offset via script when instantiating the character?


    Happy New Year! :)
     
  39. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    @LadyAth,

    Thanks, glad to hear you're liking it!

    I could add a way to set the offset via another transform if you like. Setting it via scripting would work, but a bit more tedious.

    You could also try using the empty gameobject idea on the character as the camera's main target instead and set the offset to 0, would that work?

    Happy New Year!
     
  40. LadyAth

    LadyAth

    Joined:
    Jan 17, 2014
    Posts:
    158
    Thank you, I'll try using an empty gameobject as the target instead of the character prefab. :)
     
  41. Multithreaded_Games

    Multithreaded_Games

    Joined:
    Jul 6, 2015
    Posts:
    122
    Let me preface this by saying that I love this asset and it's saved us a ton of work in having to implement and roll our own camera system--the code is very well written, documented and efficient. Customization is top-notch :)

    That being said, I am dealing with one of the most frustrating problems I've ever encountered after years of working with Unity--and while I don't believe this to be a problem specifically with your camera, I have spent countless hours trying to resolve this problem via either Unity's forums, other camera system forums, StackOverflow, you name it, I've probably read it. I'm hoping that either you or someone, anyone reading this, has encountered and has either a.) a legitimate idea as to why or b.) a legitimate solution for the problem.

    The issue is pretty much the same as described on Page 1, albeit with an additional large wall of text:

    "Why does the camera jitter the terrain using your system. I ran the RPG demo and if you rotate the camera it jitters the structures. I found this to be so using it on a procedurally generated terrain system. Therefore i went back to your test demo scenes to try it and found the same issue. Do you know about this issue?"

    No matter what I have tried, I simply cannot get rid of this problem. Flat out. My setup is as follows (I'm actually using Opsive's Third Person Controller asset, if it helps anyone)

    -Character input in Update via TPC input
    -Character movement in FixedUpdate via direct velocity updates per the TPC asset

    -Camera input in Update
    -Camera movement in LateUpdate (basically, left this the same)

    I encounter absolutely ZERO jitter while simply translating the character--the camera flawlessly tracks the character when only the camera's position is changed. As soon as I rotate the camera, however, via either mouse or joystick, an absolutely ridiculous amount of jitter is introduced. This jitter ONLY appears when the character is moving and the camera is rotating around the character simultaneously. This jitter is present when the camera both pitches, yaws, or does both simultaneously. No clues there, unfortunately.

    I pretty have exhausted every single possibility in trying to remove this jitter. At best, I can only get it to show up in other places. No permutation of Update, LateUpdate or FixedUpdate totally solves this problem. For instance, if I change the camera's LateUpdate to use FixedUpdate, the jitter does disappear while rotating and moving simultaneously. It then, however, manifests in the translation itself and the character occasionally stutters while moving. The profiler shows no spikes that should explain this behavior, IE, these are not hiccups introduced by something like, say, Garbage Collection.

    I have tried enabling 'interpolation' on the character's Rigidbody. I have no idea what this is supposed to fix--if anything, it makes everything way, way worse. I understand what it's supposed to do, but it does not seem applicable to this problem. I would love, though, if anyone actually has successfully fixed the entirety of the problem by using this method. Despite Unity's insistence, in my particular demo, this is a no-go.

    I have tried running both the camera input updates and movement updates in the same function. Again, Update, LateUpdate, FixedUpdate. I've tried stupid things like changing the script execution order. I've tried even stupider things like altering your camera code to point at the Rigidbody position of the character instead of the actual transform. No luck.

    I've tried damn near every setting on the actual camera itself, including changing auto smoothing, messing with rotation sensitivity, removing all extraneous parts of the code in an effort to make it possibly run faster (thought perhaps that when ALL of the code ran in FixedUpdate, it was getting 'behind', so to speak.)

    I've tried enabling/disabling Vsync, messing with framerate caps, changing the physics fixed timestep, messing with root motion, taking extraneous parts out of our actual scene, I've tested your demo scenes as well--to my surprise, it does seem like the Rpg Demo scene does not exhibit the problem, at least, it's hard to tell due to the way the character moves and I didn't feel like digging too much into it. I did notice, however, that Interpolation is enabled in the rigid body. Again, though, this horribly breaks my setup. That being said, I am not using animation-based root motion, but I am using an OnAnimatorMove callback (IE, root motion is not baked into the animations, but I am grabbing it using moveDelta etc.) and using that to drive the character. Again, character movement is driven by velocity updates in FixedUpdate.

    The other demo (RPG Demo Without Root Motion), however, does very clearly exhibit the problem, simply move the character forward while rotating the camera as quickly as you can, you'll definitely see the stutter.

    I am fairly confident that my ordering of code/events is correct, since the problem only is exhibited when rotating and not translating, which is quite bizarre. In conclusion, either:

    A.) My rigidbody is not entirely setup correctly. I did notice, actually, that the TPC code sets the velocity directly (translation) but does not actually mess with angularVelocity (rotation), opting instead to set transform.rotation directly. Perhaps these are out of sync and this is why the camera has issues with the rotation and not the translation.

    B.) The method in which you are actually 'looking' at the target has some issue when faced with the set of conditions that my game is using.

    Again, please do not take this as a condemnation of the asset, as I think it's great. As indicated, I believe that this problem is due to how Update, FixedUpdate and LateUpdate work in practice and unclear information. Trust me, go try to figure out all the nuances and differences between these and see whether you are more or less confused afterwards :p

    Anyhow, I know this is quite the wall of text, but it would be absolutely amazing if anyone can chime in and at least provide some sort of nudge in the right direction. I'm at wit's end here, and the only thing I know to try is to attempt to sacrifice a small animal. (Just kidding, PETA)

    Thanks again!
     
  42. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    @Liminal-LLC,

    Sorry to hear about this frustrating issue. I've been messing with my scripts to try and solve it on my end.

    I was able to fix the stutter on my demo scene (rpg non root motion) by moving the code from FixedUpdate to Update in SrpgcKeyboardMovementController.cs. Perhaps your character movement code has a similar issue?

    I also found some other minor issues in my camera script, but I don't think they're related to the jitter/stuttering issue. Just in case they are, here are the changes you can make to it in an attempt to fix it:

    This should fix the stutter in my demo scene: (if it doesn't, let me know)
    SrpgcKeyboardMovementController.cs:
    Move lines 113 - 114 to lines 106 - 107 (just under the call to method NonRootMotionMovement(); on line 105)
    You can remove the FixedUpdate method.

    SimpleRpgCamera.cs:
    Line 1390: Change Quaternion.Lerp to Quaternion.Slerp (better to use Slerp instead of Lerp for rotation smoothing, though the difference might not be noticeable)
    Line 1490: Replace what's there with _t.rotation = currentRotation; (this fixes an issue I've had with Y angle limits)

    I will include these fixes in the next update. I'll keep checking a few more things.
     
    Multithreaded_Games likes this.
  43. Multithreaded_Games

    Multithreaded_Games

    Joined:
    Jul 6, 2015
    Posts:
    122
    Hi Ninjaxim,

    Thanks for taking the time to look into this. Unfortunately none of the suggestions helped--in the case of moving code from FixedUpdate to Update, it actually made the problem noticeably worse. I am quite sure that code that alters Rigidbody properties such as forces/velocities must go inside FixedUpdate.

    The reason this works for you is because the CharacterController used in that particular sample is for non-Rigidbody movement as per the Unity docs. As such, it shouldn't be updated in FixedUpdate to begin with, if I'm understanding correctly. Of course, as I said before, it really is a complete mess trying to figure out how it is possible to get this working correctly, if at all. Again, this is not a situation unique to me and I'm perpetually astounded that Unity themselves haven't clarified this particular problem. Perhaps it really is just the case, for the majority of Unity users, that there are very few in-development 3d games using Rigidbody physics that require the kind of camera tracking that we are using.

    For our particular game, there is no way to not use RigidBody movement as this severely hampers the collision quality and moves the jitter instead to the collisions themselves. Again, I don't believe this is your fault in any way, but it is extremely frustrating, as you can imagine, having silky smooth movement and collision response but a jittery camera. Of those three things, it seems like you can only choose two o_O

    I still believe that the biggest clue is that the jitter only occurs during rotation and not translation and this was even mentioned in the earlier posting. At this point, though, perhaps someone more knowledgeable about this particular situation may chime in--if not, I might make a general topic requesting if anyone has been able to successfully solve this particular problem, specifically integration between your camera system and the Opsive Third Person Controller asset.

    Once again, thanks for your time and please let me know if you find anything else in the code that may account for or shed light on this particular discrepancy. I can provide videos and/or any other information you might need if requested.
     
  44. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    It is a strange issue indeed. I just created a simple test script to control a rigidbody (sphere) by setting the velocity directly as you described. It did have some noticable jitter on the terrain, but after enabling Interpolation on the Rigidbody the problem went away.

    I'm not sure if that's exactly how your controller is working though, so maybe you could modify it to be more like yours? It would be helpful if you could provide a script or code that has the issue and can be used in one of my demo scenes.

    Here is the code I wrote to test it if you'd like to try it yourself. Just create a sphere object, attach a Rigidbody and this script, and set the camera target to the sphere. You should see some jitter without Interpolation, and no jitter with Interpolation.

    http://unity.phatrobit.com/examples/RigidController.cs

    I hope I'm not misunderstanding your issue. If I am, perhaps you could show a video example of the problem along with some code that causes it.
     
    Multithreaded_Games likes this.
  45. Multithreaded_Games

    Multithreaded_Games

    Joined:
    Jul 6, 2015
    Posts:
    122
    Hi Ninjaxim,

    I've figured it out--it's entirely because my player character has a NavMeshAgent component attached and enabled. If this makes any sense, we were essentially using the agent to keep the character always 'grounded' without having to deal with the wonkiness of character controllers with respect to handling slopes, walls, walking off the side of cliffs, etc. This worked extremely well until we moved over to an entirely physics-based movement model (the reason we did this was to prevent collision jitter). However, now it's all very clear to me that the collision jitter in the first place was the product of having both a NavMeshAgent and Rigidbody attached to the same character. Interpolate is flat-out broken when using it on a Rigidbody that also has a NavAgent--I suppose I shouldn't say broken, as I'm sure it's working as intended, but it certainly produces 'broken' behavior.

    Funny enough, this does still work beautifully for raw movement. The question now is, at which step does the navmesh 'correction' get applied? We only really want it for its ability to keep the character permanently 'grounded', so I'm wondering if there isn't some other way to get it to be used just for that purpose without having to sacrifice much of our current project structure/code etc. Either way, none of your concern, but I just wanted to let you know that this was the issue so that if, in the future, any other poor bloke attempts this, you can give them a stern talking to. :)

    Once again, thanks again so much for your help. It was your suggestion above that led very quickly to this discovery. Take care!
     
  46. Multithreaded_Games

    Multithreaded_Games

    Joined:
    Jul 6, 2015
    Posts:
    122
    Just as an addendum, from the manual:

    "If both NavMesh Agent and Rigidbody (non-kinematic) are active at the same time, you have race condition. Both components may try to move the agent at the same which leads to undefined behavior"

    So there you have it!
     
  47. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Ah interesting, glad you were able to find the cause of the trouble. Good to know, thanks!
     
    Multithreaded_Games likes this.
  48. Multithreaded_Games

    Multithreaded_Games

    Joined:
    Jul 6, 2015
    Posts:
    122
    @Ninjaxim ,

    Came across an issue that I find extremely perplexing and is most likely a Unity3D issue. Searching for it online, of course, reveals nothing (par the course), but I wanted to post it here in case you've seen this issue before or have any ideas as to how to mitigate/eliminate it. Even using one of your demo scenes, I am able to reliably reproduce this.

    It seems like setting the cursor state is producing absurdly large and random latency spikes while I am rotating the camera with the right-mouse button held down. I've attached a few screenshots--I have to say that this is some bizarre behavior but it nevertheless is producing noticeable latency while rotating the camera. Assuming the profiler lists the calls in linear order, it looks like the very first Cursor.lockstate is the culprit.

    I'd be interested to know if you're able to replicate this--it should be fairly straightforward. Just start up the scene and rotate the camera like a madman--it should happen within a few seconds or so :)

    Thanks!
     

    Attached Files:

  49. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    @Liminal-LLC,

    Very odd, I did notice some spikes but they weren't as bad as yours. I've made some small changes to hopefully fix the issue. If you've registered your invoice # on my website here you can download the fix.

    Let me know if that helps at all!
     
    Multithreaded_Games likes this.
  50. Multithreaded_Games

    Multithreaded_Games

    Joined:
    Jul 6, 2015
    Posts:
    122
    @Ninjaxim

    Amazing response time! Thank you so very much for that, the spikes seem to be gone. Out of curiosity, what did you actually end up changing to fix the problem? At a quick glance, the code looked the same, but I didn't check it very thoroughly.

    Like always, I appreciate the stellar support.