Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

World of Warcraft Camera and Character Controller

Discussion in 'Assets and Asset Store' started by fholm, Mar 2, 2012.

  1. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    Now live at: http://u3d.as/content/fholm/rpg-character-controller-and-camera/2Jh

    Webplayer Demo: http://dl.dropbox.com/u/19877504/RpgControllerDemo/WebPlayer/WebPlayer.html

    Some of you might remember my "WoW Camera" thread from a while back, I continued on the concept of building a camera and control system for "Third Person/RPG/MMO" style games which mimic the one in World of Warcraft as closely as possible.

    It all started with me working on my own RPG game, and trying to get a nice character controller. I tried rigidbodies (like a lot of other people have on this forum), and it does not end up looking very good. I tried the built in CharacterController that ships with Unity/PhysX, it does not look very good either.

    So I opted for building my own controller, which relies on the unity Physics class to achieve the exact behavior and features that I want and expect from a camera in a modern RPG today.

    Here's a quick rundown of the features

    • Standard movement: WASD/Arrow-style, Running, Walking, Backpedal, Strafing, etc.
    • Normal gravity based actions like jumping, falling, etc.
    • Gravity is a per-character based property and not a world setting and can be toggled on/off for things like swimming over hovering
    • Walking up/down stair steps or sloped stairs
    • Able to interact and receive forces from rigid bodies, which makes it possible to use "pretty/real" physics for your effects like spells, explosions, etc. and transfer force to your character if hit
    • Support for moving platforms, elevators, etc.
    • Support for adding forces pushing your character
    • Camera supports smoothing, auto-following, panning, obstacle avoidance, all the controls you expect from an RPG camera.

    The best way to see this, is just to watch the "in action" video preview:



    I'm submitting this to the asset store over the weekend, however long it takes for the Unity guys to accept it :)
     
    Last edited: Aug 4, 2012
  2. Unicron

    Unicron

    Joined:
    Sep 28, 2011
    Posts:
    191
    looking forward to it whenever it hits the asset store.

    Don't forget to have detailed instructions on how to get it up and running :)
     
    Last edited: Mar 2, 2012
  3. justinlloyd

    justinlloyd

    Joined:
    Aug 5, 2010
    Posts:
    1,681
    Very nice package. Looking forward to snagging this from the Asset Store once it is approved.
     
  4. TouchSoft

    TouchSoft

    Joined:
    Oct 18, 2008
    Posts:
    218
    Will this work on mobile? for example.. can I use the joystick for movement and finger swipe for camera? .... if so then I'm sold.
     
  5. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    Any idea on the cost of said package?
     
  6. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    TouchSoft: I see no reason this would not work with mobile, I've used the standard unity input configuration/classes for controlls.
    Efraser2007: 10 USD
     
  7. MaliceA4Thought

    MaliceA4Thought

    Joined:
    Feb 25, 2011
    Posts:
    406
    Quick question...

    JS or C#

    Regards

    Moria
     
  8. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    C# :)
     
  9. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    It might take a few days longer to get this up as I was not able to submit it to the asset store y-day as I sliced of a fairly large chunk of my index finger with a steak knife :(

    Sadly, I'm not joking and currently typing with one hand, which is fairly slow and annoying. I'll get it up asap for both purchase through paypal directly and the asset store, but you gotta gimme a few days :)
     
  10. MitchStan

    MitchStan

    Joined:
    Feb 26, 2007
    Posts:
    538
    How was the steak? :)
     
  11. UnleadedGames

    UnleadedGames

    Joined:
    Feb 17, 2008
    Posts:
    242
    LMAO, that same question was running threw my head as I was reading fholm's post! Hope you recover quickly man! And definitly hope that steak was good after all that!
     
  12. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    I wasn't even having steak, just slicing up a tomato and the knife slipped out of my hand :(
     
  13. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    just submitted to the asset store, waiting approval.
     
  14. luvaduva

    luvaduva

    Joined:
    Feb 26, 2012
    Posts:
    10
    Looking forward to this.

    Nice work!
     
  15. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    Any news? Waiting on this so that i can modify it to work with ulink :x
     
  16. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
  17. koen.pis

    koen.pis

    Joined:
    Mar 24, 2011
    Posts:
    66
    very nice job, it beats my attempt (my camera still wasn't as smooth as I wanted it to be).

    Perfect split up for ai and network control.
    thx for sharing.
     
    Last edited: Mar 9, 2012
  18. Unicron

    Unicron

    Joined:
    Sep 28, 2011
    Posts:
    191
    Will be picking this up once I get home, very cool.
     
  19. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    Just wanted to say thanks to everyone that bought the package and all the nice comments and reviews I got, much appreciated :)
     
  20. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    Just purchased :) checking it out now.
     
  21. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    it works very well except for 1 part, i cant seem to set the run and walk animation speeds, they are wayyyyyy too fast. I tried changing run from 4 to 1 and walk from 1.5 to 1 and nothing happens the animations still play way to fast same with backpedelling. Nice job so far!



    Edit: another thing i found was when trying to walk up steps inside a house it goes right through them and pushes me through the side of the mesh and i end up outside o_O the house is on default layer and that is selected under the motor

    Before

    After
     
    Last edited: Mar 10, 2012
  22. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    I actually see what its doing, its not playing well with meshes that have generated colliders via the import fbx settings. I cant walk through from the outside but if i walk into a house i can walk right through the walls any idea how to fix that?
     
  23. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    Oh crap, it's possible that I overlooked the case of being inside a mesh collider, though I would assume that you would get a collider generated for the inside walls also? Would it be possible for you to send the me exact model that is giving you problems?
     
  24. DiegoC

    DiegoC

    Joined:
    Jan 14, 2011
    Posts:
    36
    Hi
    Can you tell me how I rotate the player with the S key and look at the camera, please?
    Thanks in advance
     
  25. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    How do you mean exactly? I'm not a 100% sure on what you want to do
     
  26. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    Efraser2007: I have been able to simulate the bug you are experiencing locally and I have a fix for it, I think I forgot to test one edgecase on mesh colliders in the end, I'll have an updated version submitted later today to the asset store and I will make sure to PM you a link with the update right away.
     
  27. DiegoC

    DiegoC

    Joined:
    Jan 14, 2011
    Posts:
    36
    Yes, when I press the D key (and the mouse button pressed) the player rotates to the right, 90 ° C, when I push the A key the player rotates to the left, 90 ° C, but when I press the S key, the player does not rotate, the player goes back to the camera, how can rotate the player to look at the camera?. Can I do all the previous movements without having the mouse button and rotate the camera around the player too, please?
    Thanks
     
    Last edited: Mar 10, 2012
  28. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    Oh, now I understand! Yes you can, but you will have to modify the Input and Animation scripts. I can do it for you sometime during the day, but I'm working on the fixes for Efraser2007 right now :)
     
  29. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    Thanks a ton! also any reason why my animation speed wont change lol?, i even tried changing the set defaults in the animator class.
     
  30. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    Actually this is the line causing the wierd animation speed bug:

    Code (csharp):
    1. Target[Running.name].speed = motor.Speed * RunningAnimationSpeedMultiplier;
    also when checking whether or not to switch to run animation your checking by speed rather than a defined walking/running state so if i change that line above to just equal the running animation speed multiplier then it never changes animations when walking i still run but slower lol.
     
    Last edited: Mar 10, 2012
  31. nicunity

    nicunity

    Joined:
    Feb 26, 2012
    Posts:
    52
    You know what would make this 10-20$ more in value - mouse support like diablo. Maybe even some rudimentary obstical avoidance.
     
  32. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    Just wanted to say that a version that works perfectly with mesh colliders is on it's way, will submit it to the asset store later tonight :)
     
  33. DiegoC

    DiegoC

    Joined:
    Jan 14, 2011
    Posts:
    36
    Thanks
    Could you include in this new version, the option to rotate the player and the camera without pressing the mouse button, please?
     
    Last edited: Mar 10, 2012
  34. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    I'll make sure to bundle the input + animator for that in the same version, yes :)

    Video update on mesh colliders:

     
  35. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    looks great also does this include a fix for walk/running and the animation speed?
     
  36. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    I'm not sure what you mean by this (I did read your post earlier), but you're supposed to keep the "Forward Run Speed" on the Input controller and the "Running Speed" on the animator at the same value, and then just modify the running animation speed multiplier to speed up/slow down the animation speed for the running. If have a "running speed" of 4 and want to play the running animation at normal speed, put the multiplier at 0.25 (4 * 0.25 = 1), etc.
     
  37. DiegoC

    DiegoC

    Joined:
    Jan 14, 2011
    Posts:
    36
    Thanks. I can't wait for test it. Thanks
     
    Last edited: Mar 10, 2012
  38. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    Ill upload a video :p
     
  39. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    Here is the video:



    Here are my settings(motor settings are default):



    the spinning happens like that when you hold down a or d and the right mouse button lol
     
    Last edited: Mar 10, 2012
  40. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    if you watch the video you can see the walk anim only plays when walking backwards when moving forwards it plays the run anim at different speeds. also i noticed the camera has the same problem with generated mesh colliders does this update fix that aswell? :p definately appreciate what you've done and thank you for this controller :)
     
  41. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    The camera will be fixed for meshes also.

    I did watch the video, I think I figured out what's going on. I'll make sure to have it fixed also for the next version :)
     
  42. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    Thanks a ton! :)
     
  43. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    Another feature you could add later on could be a fix to wall jumping haha, sliding works fine but if you keep running forward and jumping you can still get up the wall :p
     
  44. Unicron

    Unicron

    Joined:
    Sep 28, 2011
    Posts:
    191
    Just purchased this, very awesome!

    Have a small problem while I was setting up the camera controls though. The camera is not centered with the player object while I'm rotating it around, it's slightly to the right. Anyway to fix this?

    Edit:
    Nevermind, it's the Target Offset. Should have gone through the whole tutorial video first before posting. Anyway, so far so good, awesome work fholm.
     
    Last edited: Mar 11, 2012
  45. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    Got the next version, 1.1, done. Submitting it tonight and then just waiting for the unity guys to accept it.
     
  46. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    sweet then i can get to adding some ulink logic to it :)
     
  47. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    1.1 Submitted, price raised to 15$ due to the amount of time spent implementing proper mesh collisions.
     
  48. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,520
    Hi,
    Thanks for releasing this useful asset, I am a proud user now :)
    C y
     
    Last edited: Mar 12, 2012
  49. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    Hey fholm, i updated to the 1.1 version and it doesnt seem to have changed anything for me i still walk through walls with mesh colliders and cant walk up stairs with mesh colliders also the animation speed seems to be the same o_O i reimported the package as well as removed the scripts from the character and the motor and re attached them with defaults.
     
  50. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,045
    Very weird, do you think that you could send me the model you can walk through as a unity package (over a PM) and I will make sure to fix whatever is causing your troubles.

    I tested the mesh collider code on about 10-15 different models, both concave and convex, walking on an inside them without any troubles. But, anyway - if you can share the model (I will obviously not use it for anything, just to fix the code and then delete it) I will make sure it works for you.
     
unityunity