Search Unity

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,052
    You can just set the position of the player directly to make sure he ends up where he should be when the level is loaded.
     
  2. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    any idea why i cannot look rotate with the left mouse after the game window loses focus? In the editor if i click on inspector stuff etc outside of the game window i cannot look rotate with the left mouse anymore. In builds if i alt tab or click off the screen i can no longer look rotate ne more with the left mouse
     
  3. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    I've had that problem before, it only happens to me in the editor. I'm not sure why (have not seen it in a while). I will look into it.
     
  4. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    Thanks a ton! Btw i have an idea on how you can implement swimming pretty easily and painless actually if you want me to pm you the idea i will. I was actually going to program it myself but i would rather wait so that it makes reimporting and updating the asset easy and simple :).
     
  5. gdavid

    gdavid

    Joined:
    Apr 8, 2012
    Posts:
    6
    I love the RPG controller. I set it up in the Island demo but cannot get the character to cross the bridge. Tried using RPGMEsh with no luck. I was able to apply the RPGMesh to a rock and now won't walk through the rock. But no luck with the bridge. any ideas?

    edit: I was able to get the mesh to work but now cannot get on the bridge. How would I make it allow me to walk on the bridge and not fall through. right now I am stopped at the bridge
     
    Last edited: Apr 8, 2012
  6. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    298
    I need to detect if the player is clicked, so I added a Capsule collider to the PlayerHolder, I can't seem to find any problems with doing this, can you think of any?
     
  7. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    hey fholm i had a quick question, would you be able to add functionally to the gravity system and jumping to not just move downwards but also in the same direction as your moving, if i fall i shouldnt just straight drop off a cliff i should arc :) same with jumping but i assume that calculating the direction the player is moving and applying force in that direction as well as downward should fix that :). Hope all is well and thanks again!
     
  8. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    It should already be working the way you describe it, I just tested my local copy and it does do what you described. I'll look into it.
     
  9. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    298
    Hi fholm,

    I've started playing WoW and the one thing I notice between the engines is when you hold right click to look around, rather than snapping instantly, the character slowly turns after a certain angle, before that they rotate their head. Any ambitions for this kind of functionality? Also I believe you have intentions for swimming in a later version?

    I'm using your engine in a multiplayer game and without editing your code directly to send animation NPCs I'm finding the characters' animations are lagging a bit on other users computers, so before I make any major changes I'm thinking it might be clever to wait for the next version.
     
  10. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    This controller doesn't have networking features. You have to write the interpolation and extrapolation code yourself :)


    Thanks again Fholm :)
     
  11. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Great module - exactly what I needed. Any news on when the capsule collider fix will be released? The last message I saw on it was a little over a week ago.

    Thanks
     
  12. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    I'm trying to get it done as soon as I can, I am incredibly busy with my normal day job + real life responsibilities (having our first child in a few weeks, lots of stuff to do), so I've had to cut down on my unity coding a bit.
     
  13. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Yeah, I can understand that. I have a baby coming a few weeks as well. Good luck with the new addition
     
  14. imakeinternet

    imakeinternet

    Joined:
    May 4, 2012
    Posts:
    4
    Can you explain how to setup trigger objects when using your controller system? I am able to implement a typical OnTriggerEnter function when using the Unity character controller without issue, but when the same code is used with your system, it simply doesn't work. Basically what I am trying to do is simply have a gameobject, a sphere for instance, that the player walks through and I should be able to get the triggered event. Any help is greatly appreciated, and thanks in advance!
     
  15. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    put a capsule collider on the object where the script is attached and add a rigidbody aswell with gravity unchecked and iskinematic checked. this works perfectly :)
     
  16. imakeinternet

    imakeinternet

    Joined:
    May 4, 2012
    Posts:
    4
    Sadly this controller does not support Capsule Collider's.....hopefully in the future updates?? Adding a sphere or box collider yields no result. :(
     
  17. artician

    artician

    Joined:
    Nov 27, 2009
    Posts:
    345
    I picked this up after reading a description of it, expecting to be able to assign Joystick Axes to the camera controls, however I get no results whatsoever. Is this not supported? Can this be modified easily?

    Thanks for any help.
     
  18. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    It depends on what axes you configured the input manager to put the joystick movements into. You can also change the axes that is used inside the Camera and Input scripts.
     
  19. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    You've miss-understood Efraser2007 and what I meant with no support for capsule colliders. If you do what efraser said you will get trigger events that react properly. But the controller itself can't collide with capsule colliders currently.
     
  20. imakeinternet

    imakeinternet

    Joined:
    May 4, 2012
    Posts:
    4
    Everytime I add a capsule collider and rigid body to ANY object that I wish to use OnTriggerEnter with the RPGMotor complains saying capsule collider is not supported, and I do not get any debug output from my simple OnTriggerEnter function, meaning it's not being called.

    Can you explain how you do this? Thanks again! I appreciate the help.
     
  21. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651

    Attached Files:

  22. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    Just make sure the capsule collider is in a layer that's the RPGMotor is set to NOT collide with.
     
  23. artician

    artician

    Joined:
    Nov 27, 2009
    Posts:
    345
    I have the axes set up correctly in the Input manager, so there's no problem there. The joystick movement registers correctly if I use it to input in other ways (debug, etc). It works with everything but the camera.

    It might be worth noting that I am only using the RPGCamera script for my project. I did not use the RPGAnim, RPGMotor, or other scripts because I have my own character motor setup. Could this be the problem?

    Thank you for your help and quick reply!
     
  24. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    It depends on what axis you've mapped the joystick movement to, does it really map to the Mouse X and Mouse Y axes? as those are the ones used internally in the camera script. You should also be able to edit which axes are used either through the public settings on the script through the inspector or by editing it directly.
     
  25. artician

    artician

    Joined:
    Nov 27, 2009
    Posts:
    345
    As a test I changed the preset "Mouse X" and "Mouse Y" configurations to use joystick input instead of mouse input. The camera controls fine using the Mouse, but when those input axes are changed to use the Joystick, it ceases working. I can confirm that the Joystick input works appropriately, so I believe there is a bug in your script. Do you think you could take a look and provide a fix? I also welcome any more suggestions, but I am and artist and designer, and would like to avoid digging through the script myself.

    Many thanks.
     
  26. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    I would if I could, but I do not have access to a Joystick locally, I think the only thing I can dig up is an XBOX 360 controller, I could try with this.
     
  27. imakeinternet

    imakeinternet

    Joined:
    May 4, 2012
    Posts:
    4
    Thank-you so much! This worked perfectly. I appreciate your assistance more than you know. Thanks to Efraser2007 also who has been an incredible help. I'm so happy now that they are working. Cheers and thanks for such a great camera addon.

    *EDIT*

    I stumbled across a small issue, which happens when my trigger object is touching the terrain. It appears that when I try to set the transform of the player upon entering the trigger to anything it does not want to move (I am assuming clamping is getting in t he way?) However when I jump up in the air and land back down on my trigger, it will move the player without issue.

    Thoughts?
     
    Last edited: May 7, 2012
  28. artician

    artician

    Joined:
    Nov 27, 2009
    Posts:
    345
    Please do! I purchased your tool specifically to use with a controller setup. Would be a shame if it didn't support them after all.

    Thank you.
     
  29. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    Well technically you should be able to do fholms suggestion, under your player object create an empty game object and add a capsule collider(or whatever other shape collider you want) and set it up as a trigger. Then add a rigidbody change it to is kinematic and uncheck gravity enabled. Now you can create a new physics layer and change the settings for it under physics settings and make sure it doesnt interact with default or whatever your terrain object's layer is. Once you do that change the empty game object you made to the new layer and attach the script that you are using to detect collision and you will be all set. That should fix it.

    Step 1: Create an empty game object.

    Step 2: Drag the empty object onto your player object and reset its position and rotation.

    Step 3: Create a new physics layer and make sure it doesnt interact with the layer the terrain is on which is usually default by default.

    Step 4: Change the layer of the game object you created to the new physics layer you made.

    Step 5: Add a capsule collider(or any other shape collider) and check the is trigger check box.

    Step 6: Add a rigidbody to the empty gameobject and check is kinematic and uncheck gravity checkbox.

    Step 7: Attach the script you are using to detect collision and Presto it should work.
     
  30. artician

    artician

    Joined:
    Nov 27, 2009
    Posts:
    345
    I realized the issue I was encountering: It was stupid of me to not realize the camera system still expects a keypress in combination with the axis of movement. I hope I didn't waste anyone's time.

     
  31. Tallenz

    Tallenz

    Joined:
    May 9, 2012
    Posts:
    11
    Is it difficult to add additional animations to this controller?

    I need to be able to perform certain actions such as using objects, sitting down, etc. I don't mind adding them into the script myself I just need to know how difficult this is going to be (Beginner level, mid level, expert?). Basically I will need it to be able to complete the animation I indicate (which means a constant idle check is a no-no and needs to be modifiable). I am currently using my own camera and controller I made out of patching together different things and it is truly abysmal...

    Not worried about using the controller in a multiplayer situation right now, but will need that eventually too so if there are plans for that even better.
     
  32. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
  33. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
  34. mariovermeulen

    mariovermeulen

    Joined:
    Oct 1, 2010
    Posts:
    16
    Hi

    I am using your RGP Controller and am having a problem with the RPG Anim I have filled in all the animation but keep getting the following error

    NullReferenceException
    RPGAnim.PlayAnimation (System.String name, UnityEngine.AnimationClip clip, Single speed) (at Assets/RPGController/RPGAnim.cs:270)
    RPGAnim.OnMove () (at Assets/RPGController/RPGAnim.cs:164)
    RPGMotor.InvokeCallback (System.Action action) (at Assets/RPGController/RPGMotor.cs:218)
    RPGMotor.Step () (at Assets/RPGController/RPGMotor.cs:469)
    RPGMotor.LateUpdate () (at Assets/RPGController/RPGMotor.cs:354)

    Any ideas?
     
  35. mariovermeulen

    mariovermeulen

    Joined:
    Oct 1, 2010
    Posts:
    16
    Ok fixed it i place the rpganim on the player object and not on the model itself
     
  36. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    oh and also the camera on games like world of warcraft rotate the camera upwards when hitting the ground they dont move in towards the player. is there any way you can add that functionality?
     
  37. E2R_Ben

    E2R_Ben

    Joined:
    Oct 30, 2009
    Posts:
    143
    Hey fholm, Ive just bought your package and think its awesome - my client literally said "make the camera like it is in WOW" and your package does just that, so thanks!

    I know you may be busy with other requests, but my client would really like to see a first person option added to the camera. If it sweetens the deal I can send some more money your way!

    Also, would anyone be able to tell me the answer to these questions:

    I am a bit confused how colliders work. I can walk on objects with mesh colliders (like the floor I have made), however I walk through other objects with mesh colliders on. I also have stairs which I can jump on to, but when I walk towards them I pass though. Finally when i add a box collider and remove the mesh collider this seems to work. Everything is on the same layer to eliminate that problem. How is this working? Is there a bug here?

    How can I turn off run? im making a realistic simulation, where players don't run. Or at least how do i make the amount of time it takes from walk to break into run less.

    Good package though, keep up the work and im sure people will happily pay more for it.
     
  38. artician

    artician

    Joined:
    Nov 27, 2009
    Posts:
    345
    Hi,

    I'm very happy with this plugin. The camera system works exactly as I would hope, with even more features than I was expecting.

    I have a serious problem with it though and I hope you can help - roughly 50% (or more!) of the time when I import the package into a project, whether it's a project that I have been working on for some time, or a brand-new project I just created, Unity will crash.

    Unity does not crash when importing any of the dozens of other plugins and tools that I have purchased from the Asset store. When this happens it appears that the package will partially import some of the files, as the RPGController directory will be in my Project view when I open Unity post-crash, however I cannot tell if all the RPGController assets imported correctly or if there are residual bugs.

    Can you offer some insight into what might be causing Unity to crash when I import your system? Is there anything out of the ordinary contained within it? Unity gives no error message when this happens, but it happens far, far too often.

    Thank you for any help.
     
  39. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    RazzMattazz: If you're "passing through" your mesh colliders there could be a problem with the winding order of the polygons, as you will always be able to pass through a mesh collider from "the inside", and if the winding order is flipped, then the "inside"/"backside" will be facing outwards.

    I would in general not recommend using mesh colliders at all, not because they are buggy (as far as I know, at least) but because they tend to be slow and give very erratic movement due to polygons not always being perfectly aligned, etc. I added mesh collider support as it was something requested by several people, but personally I almost never use it an manually wrap my meshes in box/sphere colliders.

    If you want I could take a look at your exact problem, assuming you can send over a stripped down project with the camera setup and the meshes that give you troubles. Though I may be short on spare time in the next month or so due to my wife giving birth to our first child any day now. Turning of running can be done by modifying the script slightly and turning on the "toggle walk" key constantly.

    artician: I'm glad you like it! But I'm sorry that I have to say that I have no idea what could be causing the crashes when you import the package, I have never seen this before (nor has anyone else reported it). So to be honest I have no idea, I've probably imported the package on 20+ computers by now and never had this problem.
     
  40. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    Hjupter Efraser: I will release an update to the controller, but I am very short on time currently due to a huge project that is running at work and my first child being expected any day now.
     
  41. markfrancombe

    markfrancombe

    Joined:
    May 26, 2009
    Posts:
    155
    Hmm I guess the baby came?

    I picked up the Controller 3 weeks ago, and Im afraid had limited success with it. But I really don't know what I'm doing wrong.

    If I simply RUN the Viking demo, it worked exactly as I would like my character to work, (with one small exception. maybe this is a setting. When STOPPED MOVING and the character is Idling, and THEN I press A or D to change direction, the camera does NOT move around behind the rotating character.

    However I have BIGGER issues. When I try to implement MY character, I get very funky results.

    Firstly I have tried my character IN the demo scene, just rplacing the Viking with mine, and reconectinf the animation files. This worked for forwards and jump, but the character would NOT turn.. at all A and D not working. (I can see a tiny movement, but not a proper turn) Is this a setting?

    Secondly and Worse... If I add the package to a totally CLEAN project, just the package and my character, then follow the instructions, I get to page 5:
    But no moving, the charater rotates, but no movement... I completed the instructions, but didnt help...

    I have done this about 15 to 20 times, with new scenes and a couple of different characters, but to no avail.

    The best result I have is by replacing the Viking, but he doesnt turn...
    Im wondering if my characters animations are the problem. I notice that alot of people use thus Viking@run way of doing the files for animations... I collected my animations from various sources, and test them on my character directly, by adding the anim files to the Animation slots of the charater... do I NEED to have all these @ prefabs fr it to work...? I think not as the Juma nd run animations ARE WORKING.

    Sorry for big post, and I hope ANYONE will answer if they can help, maybe fholm has diapers to change?

    Mark
     
  42. mariovermeulen

    mariovermeulen

    Joined:
    Oct 1, 2010
    Posts:
    16
    Check that the animations where made for the same model and that all part of the model has the same names on all items, eg in my model the animator renamed the neck to m_neck and the legs from legleft and legright to r_leg and l_ leg halfways through creating the animation which resulted in a problem in half the animations working and the other half not. hope this helps a little.

    and just for info my character is working properly.

    Regards

    Mario
     
  43. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    Hey!

    I just wanted to say that my baby is out and it's a healthy (and pretty chubby) boy, I will try to help all the people that have posted in the thread and messaged me privately with various issues, also to put out a 1.4 version with a bunch of fixes. I will try to help during next week, as I start work again, and maybe put out the 1.4 version within 3-4 weeks.

    /F
     
  44. markfrancombe

    markfrancombe

    Joined:
    May 26, 2009
    Posts:
    155
    Congratulations!
    Remember all you have to do is keep the dry end wet and the wet end dry...

    Mark
     
  45. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Congrats for the baby :)
     
  46. markfrancombe

    markfrancombe

    Joined:
    May 26, 2009
    Posts:
    155
    Hmm thanks for the response Mario, Im certainly NOT sure that all the animations were made for the same model. However...

    To test that they all work, I simply chuck the .anim file at the characters idle slot and press play, and whatever animation it is, the character will do.. I have even tweaked a few animations in the Unity Animation window.

    Surely this is proof that the animations are OK?

    Im still fiddling... if I could get the keys A and D to work (the charater to turn, I think the other issues could be fixed with settings...

    But even with the run forwars that DOES work, sort off, Im having very intermittent operation. Sometimes the animation doesnt play, and man just slides... sometimes if I hit the toggle run key (left shift) THAT will make him walk OK...

    BUt IM working with it and I certainly appreciate the hint... but i think all my animations are ok, I just didnt know if it was OK just to chuck them at the animation component an NOT have all the @run @walk @jump files...??
     
  47. markfrancombe

    markfrancombe

    Joined:
    May 26, 2009
    Posts:
    155
    OK, I just wanted to say that I just got it to work.
    For those that may have simerlar problems, I had to be absolutely sure that when the character dropped from his initial few feet above ground, he was in NO way going under the terrain plane. I discovered that by simply adjusting the Y Position on the main models transform, I got him out of the mud so to speak, allowing him to move.

    Theres a bit of tweaking to be done, so I think I can get it to improve a little, but I have a few major gripes/issues.. some maybe be STILL my fault, but some maybe design issues I think. I would be very exited to hear if anyone has simerlar issues.

    1. turning while stopped. My character DOES NOT play the walk animation that I have set to be "OnStrafe" or an animation, IF I try to rotate him while on the spot, I dont have a specific "Shuffle" animation, but I would make one. As he rotates he really needs to shuffle his feet a bit.

    2. Camera while stopped. And in the same situation, why doesnt the camera move around when I rotate (A&D) the character while stopped.

    3. Is there a way to have Walk as the default rather than run?

    4. And "Toggle Run" (the left shift key) is NOT toggle, but momentary. So I have to keep the key pressed down the whole time I want to walk. I want a run/walk key, press once, he walks, press once he runs... right now, if I lift my fonger off the key, he runs... if I press he walks.

    5. Jumping. OK I dont have the correct anims just yet, I have just a complete jump animation, where my character bend his knees, to create lift, he jumps and lands. I see that I need a separate landing animation, Ill try to split this up a bit.
    However, I can see that the my animation isnt triggering until the character is already in the air, so the "flying up in the air" part of a jump sequence is just my Idle animation as the guy levitates magicaly...
    Second thing about jump, its only triggering my jump anim EVERY OTHER JUMP. Once it works, then it doesnt, then it works, then it doesnt.

    6. Zooming while walking, just not happening... I would be able to zoom in as I run...

    Er.. thats about it...

    Opinions? fixes? Help?


    Cheers

    Mark
     
  48. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    markfrancombe: I am sorry that you're having so many problems with setting it up, I know some people have had smaller issues, but nothing on the scale you're describing (and I've sold about 150+ units of the controller so far).

    2. This is a design choice by me, this can be fixed by changing the code on what triggers the camera to follow
    3. Yes, by changing the code in the input controller
    4. This can be changed also in the input controller small changes to the code
    5. I'm not sure why you're only getting the jump anim to trigger every other jump, this is incredibly weird (I have not seen it so far)
    6. Also never seen this issue before.

    The only thing I can offer is that you send over your character model, including animations, prefabs, etc. it has and I can try to set it up for you in an empty scene.

    /F
     
  49. markfrancombe

    markfrancombe

    Joined:
    May 26, 2009
    Posts:
    155
    Wow, thats incredibly kind of you! Maybe I can hold off having to do that right now.

    I tried again with a new clean set-up and had better results, I have lost the Jumping probelm, it seems to trigger ok on every jump now, PLUS the zooming while moving is also working.

    So thats most things working properly now.

    JUST ONE THING WRONG STILL
    Im expecting to see an animation when I turn on the spot (Point 1 on my post above) Im just getting him spinning right now...

    As for points 2, 3 and 4. Im not sure I can code the changes I require here (maybe I could do 3, as Im guessing thats just to swap walk and run...)
    Any likelyhood you might consider implementing my other suggestions as options? Or post the code? Pretty please? with a cherry? I'll babysit?

    ;)

    To recap that was to rotate the camera WITH the character rotation WHEN stopped and have walk as the default...

    OOPS I have one more suggestion, but thats just cos I have not got a good jumping animation for my character. I have one which looks OK while running, and one that looks ok while stood still, but NOT vice versa.

    Any chance of triggering a different jump animation if moving?

    Its all beginning to look pretty good now, But now I'm in Tweakville Arizona..

    Cheers

    Mark
     
  50. EarthLaunch

    EarthLaunch

    Joined:
    Mar 7, 2012
    Posts:
    62
    For anyone who wants a temporary and horrible hack to keep the camera from going underground for a moment when you quickly move it down; place this in RPGCamera.cs just before the end of LateUpdate(), it will make it 'collide' with the ground:

    Code (csharp):
    1.         RaycastHit hit;
    2.         float checkHeight = 8f;
    3.         if (Physics.Raycast(transform.position +new Vector3(0, checkHeight/2, 0), Vector3.down, out hit, checkHeight, Obstacles)) {
    4.             float calculatedDistance = (hit.point -(transform.position +new Vector3(0, checkHeight/2, 0))).magnitude;
    5.             if(calculatedDistance < checkHeight/2 +1.5f) {
    6.                 transform.position = new Vector3(transform.position.x,hit.point.y +1.5f,transform.position.z);
    7.             }
    8.         }
    (No promises this will work for your project. Could be optimized.)