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
    On sale for 50% off until Feb. 1st, 2018.
    This package will be deprecated at that time. I will provide additional support until March 1st 2018.


    Description:
    The goal of the Simple RPG Camera package is to provide an easy to implement, no hassle camera control script that is packed with all the features you'd expect it to have and more. It's designed to work very well with RPG styled games (a WoW or Diablo style), and can be easily integrated into projects of any size without making a mess.

    Price:
    $15

    Package Includes:
    • Camera control script that works on both desktop and mobile
    • Player control script for desktop and mobile
    • A character model from one of my own projects
    • Mecanim and Legacy support
    Support:
    If you have questions / comments / suggestions / problems, reply to this thread, visit our forum or email us at phatrobit@gmail.com.

    Basic Setup Tutorial:


    Mobile Use Example (provided by sjm tech):
     
    Last edited: Jan 3, 2018
  2. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Version 1.2.1 has now been sent to Unity for review.

    Here's the changelog:

    SimpleRpgCamera.cs + MobileSimpleRpgCamera.cs:
    • Added Collision Style
      • RPG style is how collision worked previously (the camera is pushed in front of obstructions)
      • TopDown is a new style, which fades objects out rather than moving the camera in front of them (requires transparent shaders)
    • Added Collision Alpha: This is the alpha value for the faded objects when using the TopDown Collision Style
    • Added Collision Fade Speed: The fade speed for the TopDown Collision Style
    • Added Allow Rotation: Prevents or allows camera rotation control
    SimpleRpgPlayerController.cs + MobileSimpleRpgPlayerController.cs:
    • Added CLick To Move: When enabled allows the user to click a location for the player to move towards
    • Added Clickable Tags: Objects with a tag in this list will be clickable for Click To Move
    SimpleRpgPlayerController.cs:
    • Added Keyboard Control: Enables the use of keyboard controls or not
    Scenes:
    • Added a top down demo scene to showcase the new top down camera style and player control
    • Updated the mobile demo scene to use the new top down camera style and player control
    Bug Fixes:
    • The camera is no longer choppy when moving and rotating.
    Edit: Wow, I sent in the update 20 minutes ago and it's already been accepted!
     
    Last edited: Oct 11, 2013
  3. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Version 1.2.2 is up for review.

    Changelog:
    SimpleRpgCamera.cs + MobileSimpleRpgCamera.cs:
    • Replaced Collision Style with Collision Alpha Layers allowing the use of both object fading and object collision
    • Created a custom inspector to clean things up and make it easier to find each setting
    • Added Target Tag which searches for a target with the specified tag instead of setting the target directly
    Bug Fixes:
    • The camera now rotates around the Target Offset position correctly
    • Object fading had a problem where, depending on the object position, would not fade back in correctly, but is now fixed
     
  4. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    Just bought and its very nice to use. very polished camera control.
    anyway can i request few things?
    could you add the possibility to strafe left/right and rotate the camera on mobile with swipe?
    and make the character control work with mecanim ?
     
    Last edited: Oct 12, 2013
  5. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Thanks!

    I am very open to requests. A rotation swipe control for mobile is a nice idea and I will definitely work on that. For strafing on mobile, do you mean with button controls or by swiping as well?

    As for Mecanim, I am currently developing this asset in Unity 3.5.7, so that would require Unity 4. Anyone who owns my asset that's still using pre 4.0 will no longer be able to download the updates. I have been considering upgrading it though so I can use things like Mecanim, so I will definitely convert the existing character script (or add a separate one) for Mecanim if I ever do so.

    I am also planning on adding controller support for the camera as well in the near future.
     
  6. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    for strafing with a dpad or WASD and then rotate the camera with right bouton or with a swipe
    about mecanism its a really interesting option for everyone, could have a package for mecanim inside you main package to avoid problems.
    the problem with your controler is that anim name are write in the script so we cant adapt it with different players,
    maybe put the strings for each animation in the inspector and an option like if strafeLeftString = "null" dont play the animation ( in the case where we only have 1 walk/run animation)
     
  7. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Ah I see. I will do some work on the player control scripts as well to try and make them more modular and customizable through the inspector.

    I will see what I can do for including Mecanim support, but at most it will only be a separate player script until I decide to upgrade the project to Unity 4.
     
  8. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Version 1.2.3 is now being reviewed.

    Changelog:
    • SimpleRpgCamera.cs
      • Added Alternate Rotation Keys under Rotation Settings > Allow Rotation. This allows camera rotation with key presses as an alternative from the mouse
    • MobileSimpleRpgCamera.cs
      • Rotation is now controlled by swiping
      • Removed obsolete rotation settings
    • MobileSimpleRpgPlayerController.cs
      • Updated movement control to be friendlier with the camera (don't move while zooming / swiping)
    • MobileDemoGUI.cs
      • Simplified to just display version info and quit button
    • Bug Fixes
      • Fixed a raycast error that occured when distance was 0
     
  9. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Version 1.2.4 is now being reviewed.

    Changelog:
    • Bug Fixes
      • Fixed raycast error yet again
      • Return/Rotation Smoothing can no longer be less than 1
      • DemoGUI and MobileDemoGUI no longer generate errors when the camera / player variables are null
      • Updated readme.txt to match current camera inspector values
     
  10. Kintaro

    Kintaro

    Joined:
    Jul 9, 2012
    Posts:
    2
    Hi, I just bought your asset.
    excellent work.

    I get an error that looping can you help me?
    (sorry I do not speak very little English)

    Unity version : 4.2.2f1

    during installation of the asset
    Error 1 :
    m_InstanceID == 0
    UnityEditor.AssetPreviewUpdater:CreatePreviewForAsset(Object, Object[], String)


    error given in the examples offered
    error 2 :
    UnityException: Input Axis Mouse ScrollWheel is not setup.


    Thank you
     
    Last edited: Nov 12, 2013
  11. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Thanks Kintaro and I'm glad you like it!

    This can usually be ignored.

    The Mouse ScrollWheel axis should automatically be created by Unity when you start a project. If you don't have the axis in your input settings, this can be fixed by adding a new input located in Edit > Project Settings > Input with the below settings (copied from Unity's defaults):

    Name: Mouse ScrollWheel
    Descriptive Name:
    Descriptive Negative Name:
    Negative Button:
    Positive Button:
    Alt Negative Button:
    Alt Positive Button:
    Gravity: 0
    Dead: 0
    Sensitivity: 0.1
    Snap: false
    Invert: false
    Type: Mouse Movement
    Axis: 3rd axis (Joysticks and Scrollwheel)
    Joy Num: Get Motion from all Joysticks
     
  12. milox777

    milox777

    Joined:
    Sep 23, 2012
    Posts:
    195
  13. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
  14. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Version 1.3.0 has just been sent to Unity for review. For this update I have upgraded the package to Unity 4.3 due to many requests for Mecanim. If you still use Unity 3.5, contact me and I will try to work something out so you can get the update as well.

    If you do not want to wait for Unity to review the package, contact me at phatrobit@gmail.com with your invoice number and I will send you the package directly.

    Changelog:
    • General
      • Upgraded project to Unity 4.3
      • Added mocap animations for use with Mecanim
      • Added a joystick control for mobile
      • Rebuilt the demo scenes
      • Cleaned up deprecated code
      • Deleted old player controller scripts
      • Deleted old player animator scripts
      • Deleted mobile demo gui script
      • Added new MouseMovementController script
      • Added new KeyboardMovementController script
      • Rebuilt player prefab to use Mecanim instead of Legacy
    • MobileSimpleRpgCameraEditor.cs
      • Fixed an issue with the Objects To Rotate and Objects To Fade fields
     
  15. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Version 1.3.1 is now being reviewed by Unity.

    Changelog:
    • General
      • Updated and reorganized demo sources to work better with other PhatRobit products
    • SimpleRpgCamera.cs
      • Script now generates an empty GameObject (_SRPGCinvisibleTarget) to support new RTS style edge scrolling movement
      • Target Settings:
        • Added Lock To Target
        • Added Allow Edge Movement
        • Added Edge Padding
        • Added Scroll Speed
        • Added Follow Target Key
        • Added Alternate Camera Scrolling Keys
        • Added Show Edges option
      • Rotation Settings
        • Added Right Click Origin option under Return To Origin setting
    • SrpgcMouseMovementController.cs
      • Added support for characters that don't use Mecanim's animation for movement
     
  16. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Version 1.3.2 is now being reviewed by Unity.

    Changelog:
    • General
      • Renamed demo source folder to SRPGCSources
    • SimpleRpgCamera.cs
      • Target Settings
        • FIX: Edge movement now works correctly when camera is rotated
      • Rotation Settings:
        • NEW: Togglable mouse buttons for Allow Rotation
        • NEW: Togglable lock cursor for individual mouse buttons
     
  17. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Version 1.4.0 is now being reviewed by Unity.

    Changelog:
    • Scenes
      • NEW: MobileSRPGC - Rotation Test
    • SimpleRpgCamera.cs
      • NEW: Movement Settings
        • MOVE: Edge movement settings moved here
        • NEW: Options for allowing edge / key movement or not
        • NEW: Limit Bounds
          • NEW: Boundary Origin
          • NEW: Boundary Size
    • MobileSimpleRpgCamera.cs
      • NEW: Movement Settings:
        • NEW: Allow Panning
        • NEW: Pan Type (Drag)
          • NEW: Panning Sensitivity
          • NEW: Panning Touch Count
        • NEW: Pan Type (Swipe)
          • NEW: Pan Amount
          • NEW: Pan Speed
        • NEW: Panning Allowed Directions (X / Y)
        • NEW: Pan Invert Direction (X / Y)
      • Rotation Settings:
        • NEW: Rotation Type with Drag or Swipe option
        • NEW: Swipe Active Time
        • NEW: Swipe Min Distance
      • Zoom Settings:
        • NEW: Invert Direction
    • SrpgcJoystick.cs
      • FIX: Animator now always runs forward according to camera direction
      • NEW: Instant Rotation option
     
  18. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Version 1.5.0 is now being reviewed by Unity.

    Changelog:
    I have rewritten most of the code in SimpleRpgCamera.cs to clean things up and allow a new feature.
    The new feature (Use Target Axis) can be seen on the new scene SRPGC - Orbit Demo

    • Scenes
      • NEW: SRPGC - Orbit Demo
    • SimpleRpgCamera.cs
      • Collision Settings:
        • NEW: Collision Buffer
      • Target Settings:
        • NEW: Use Target Axis
     
  19. snakebane

    snakebane

    Joined:
    Jun 30, 2012
    Posts:
    7
    This gets better with every update, thank you!
     
  20. snakebane

    snakebane

    Joined:
    Jun 30, 2012
    Posts:
    7
    In version 1.5, I noticed I lost zoom with mouse scroll wheel functionality. Am I overlooking a setting somewhere?
     
  21. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Hmm, be sure Allow Zoom is enabled under Zoom Settings. If it is and you still cannot zoom with the scroll wheel, also check to be sure you have Mouse ScrollWheel in the Input Settings under Edit > Project Settings > Input.
     
  22. snakebane

    snakebane

    Joined:
    Jun 30, 2012
    Posts:
    7
    Thanks, I didn't have the option until I re-imported the package. I installed 1.5, then upgraded to unity 4.3.4 so I created my own problem when I didn't pay attention to the unity version requirement. Thanks again!
     
  23. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Ah! Glad you were able to figure it out. I didn't think of that being the problem.
     
  24. melphick

    melphick

    Joined:
    Dec 29, 2013
    Posts:
    5
    I'm trying to set up an RPG within unity designed for mobile.

    Ideally I would like to have a tap to move to that location (already implemented) , but am having a hard time to alter the code (i'm relativitly new to coding) so that a single tap and hold swipe moves the camera around the character.

    Currently it seems to clash with the tap to move and can't seem to figure out how to do it so it doesn't not conflict with other actions.
     
  25. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Hm, yeah that is an interesting problem.

    I have played around with it and came up with a simple solution. I modified it so that to move you have to hold it for a specified amount of time. That way you can set it to the same duration as the swipe detection time on the camera so it is impossible to move the character while it is still possible to be swiping.

    If you would like to test the new code, please send your invoice number to phatrobit@gmail.com (to verify the purchase) and I will send you the package.

    Here is an APK if you have an android device and would like to try it out with my top-down demo:
    http://unity.phatrobit.com/productdemos/SimpleRPGCamera.apk
     
  26. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Version 1.5.1 is now being reviewed by Unity.

    Just a few small fixes and updates this time around!

    Updated the readme file

    SrpgcMouseMovementController.cs:
    NEW: useTouch
    NEW: touchDelay
    FIX: Can now use swipe rotation without moving character

    SimpleRpgCamera.cs + MobileSimpleRpgCamera.cs:
    FIX: Zoom distance is no longer clamped while colliding
     
  27. melphick

    melphick

    Joined:
    Dec 29, 2013
    Posts:
    5
    That's awesome, I'll send you an email at weekend and see if it works as I desire it too,

    Thanks.
     
  28. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Versoin 1.5.1 has actually just been accepted by Unity, so you can just go ahead and download it from the Asset Store. It includes the updated mobile movement code that you requested.

    Let me know if there are any problems!
     
  29. IndieGameHustle

    IndieGameHustle

    Joined:
    Jul 25, 2012
    Posts:
    66
    Hi,

    I purchased your script was hoping to use it in my game but using a Xbox Controller.
    I don't see a option for 4th Axis and 5th Axis.


    Any help would be great!


    Thank You
     
  30. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Hello!

    I have not done any testing with controllers, but I can most certainly do so and will get back to you soon!
     
  31. IndieGameHustle

    IndieGameHustle

    Joined:
    Jul 25, 2012
    Posts:
    66
    Thank You So much!!! looking forward to it.
     
  32. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Sorry been slightly busy lately, but here's something to try.

    My script uses Mouse X and Mouse Y in the Input Manager (Edit > Project Settings > Input). You can try changing the Joy Num parameter to your joystick 4 and 5 axes.

    I have not tested this so let me know if that works, if not I will do some testing!
     
  33. IndieGameHustle

    IndieGameHustle

    Joined:
    Jul 25, 2012
    Posts:
    66
    Hi, Thanks for getting back.
    But nope that does not seems to work.
    Joy Num only has The number for which Joystiq we are using.
    Axis is above that which allows us to change it to Axis 4 or 5.
    I even changed the type from mouse to Joystick and still no go...
    Of course I could be missing something but based on what I tried it didn't work. :(
     
  34. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Ah ok, I did some testing and found that you need to change the axis Type to Joystick Axis, and the Axis to 4th / 5th axis (x / y). That will get input from the right joystick on an xbox controller instead of the mouse.

    You then need to go to line 218 in SimpleRpgCamera.cs and add something (I just added 'true') to the if statement for it to actually use the input, otherwise you will have to be holding the mouse button down for it to work.

    Code (csharp):
    1.  
    2. if(_controllable
    3. allowRotation  ((allowRotationLeft  Input.GetMouseButton(0)) ||
    4. (allowRotationMiddle  Input.GetMouseButton(2)) ||
    5. (allowRotationRight  Input.GetMouseButton(1)) ||
    6. true))
    7. {
    8.  
    I can add a control type dropdown or something in the next update that will let you select either mouse or joystick input, or both.
     
    Last edited: Mar 26, 2014
  35. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    is it possible to have a legacy animation version for mobile?
     
  36. IndieGameHustle

    IndieGameHustle

    Joined:
    Jul 25, 2012
    Posts:
    66
    Great!
    I will try this right away, thank you!

     
  37. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Sure, I will add that to my todo list for the next update!
     
  38. IndieGameHustle

    IndieGameHustle

    Joined:
    Jul 25, 2012
    Posts:
    66
    Just in case others are seeing this and using this code edit:
    If the camera is still moving adjust the camera Mouse X and Mouse Y Dead to something like .1.
    this seems to keep it from moving.

    Thanks Ninjaxim.
     
    Last edited: Mar 27, 2014
  39. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Awesome, glad it works! I will try to implement a cleaner solution in the next update.
     
  40. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    514
    I don't think the movement settings and limit boundaries are working. The documentation does not explain how this is meant to work either !

    Is it meant to stop the player from moving outside the boundary with Origin and Size. Settings these values my players moves straight through them and looking at the code there is nothing to stop this happening because "target" is never assigned in the camera script with _focalPoint?

    Can someone help me understand how to do this please?
     
  41. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Limit Bounds limits the camera's movement to the specified area (origin / size). Turning on the movement settings allows you to move the camera away from the target kind of like a real-time strategy game.

    Sorry my documentation isn't too great, I really need to just sit down and work on making it nice!

    Were you expecting it to work differently than it currently does, or there is possibly a bug?
     
  42. melphick

    melphick

    Joined:
    Dec 29, 2013
    Posts:
    5
    I was just about to email you to ask for Camera control via another joystick.

    Been using the Unity for PSM (Vita) and was struggling setting it up, the method on pg2 doesn't seem to want to work, but I'll give it another shot in a clean project tomorrow.
     
  43. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Version 1.5.2 is now pending review by Unity.

    Changelog:

    Updated the ReadMe file
    Added Legacy player model and files

    SimpleRpgCameraEditor.cs:
    FIX: Inspector should now save modified values on prefabs

    SimpleRpgCamera.cs:
    NEW: Added public RotateObjects function to manually force objects to face forward relative to the camera
    NEW: Added Relative Offset Setting

    MobileSimpleRpgCamera.cs:
    NEW: Two Touch Rotation (thanks Paul!)
     
  44. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    514
    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?
     
  45. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    I did not know about this, I'll take a look soon. I'm currently fighting a bad cold.

    Thanks for letting me know!
     
  46. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    I tried things out but everything is nice and smooth for me. Have you tested it on more than one computer with the same result?
     
  47. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    514
    Yes i tried it on my quad core PC and my Mac Pro same issue. I'm wondering it its something to do with the Unity Terrain System but to re-create this issue do the following:

    1. Just make a little rotate pivot script attach the camera
    2. StayBehindCamera = true
    3. The unity terrain and objects on it jitter as the camera pans around it

    As i said i'm not entirely sure its your camera system causing it, as i tried the kolmich camera solution with same suspicious results very perplexing.
     
  48. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Strange. It may have something to do with the VSync setting in the quality settings. With VSync set to Every VBlank I do notice a slight jitter or lag while rotating, but only in the editor. It doesn't seem to affect the standalone build at all.

    Do you still have the jitter in a standalone build of your project? If so, maybe try disabling VSync in the quality settings and see if that's the cause?

    It must not be my script causing the issue if it also happened with a different one.
     
  49. hamyshank

    hamyshank

    Joined:
    Jan 31, 2013
    Posts:
    88
    The "jittering" is caused when the target and camera are running different update methods. Since this camera system runs in LateUpdate then if your target is running in a FixedUpdate you will see these jitters. It's the same with all camera systems.

    One interesting thing to note is that if you take a look at the new Sample Assets from Unity - their third person camera has a setting that allows you to switch the camera from LateUpdate or FixedUpdate right in the inspector. Since changing the targets update would be much more involved.

    My original reason to post was to request leaving out the shaders that have seemed to take over my project? It looks like a toon shader or something. It's on my terrain and everything. How can I disable this?
     
  50. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Ah, sorry for the late reply I didn't get an email notification this time strangely.

    For the shader, all you should need to do is delete the ToonTerrain shader located in PhatRobit/Demos/SRPGCSources/Shaders.

    As for the jitter, does your character use a rigidbody? If so, have you tried setting the Interpolate setting to Interpolate? I read some posts that say that fixes it, but if not I can take a look at the sample asset and see what I can do about adding a way to switch it from LateUpdate to FixedUpdate.