Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

3rd Person Camera - emulating the World of Warcraft camera with Smart Pivot and Thickness Checks

Discussion in 'Assets and Asset Store' started by Enzi, Feb 3, 2016.

  1. unity_QiUlE25oqh9S_w

    unity_QiUlE25oqh9S_w

    Joined:
    Nov 9, 2019
    Posts:
    2
    Hey, great asset! Is there any way this works on mobile?
     
  2. unity_QiUlE25oqh9S_w

    unity_QiUlE25oqh9S_w

    Joined:
    Nov 9, 2019
    Posts:
    2
    Ah I just noticed this answer. What exactly do you mean by a plugin that can map the mouse movement? Would we have to go into your code and manually change the mouse inputs to a touch, or is the plugin you mention something which would handle this automatically?

    Thanks :)
     
  3. VoldemortEatsBurgers

    VoldemortEatsBurgers

    Joined:
    Jun 28, 2021
    Posts:
    6
    Hi Enzi! Please check your e-mail!
     
    Enzi likes this.
  4. phildragon

    phildragon

    Joined:
    Apr 4, 2014
    Posts:
    9
    Interesting. From the 2nd screenshot, how do you do "Right_3", "Right_4" and "Right_5".
    I easily found Horizontal and Vertical, but not "Right_3", "Right_4" and "Right_5".
    Thanks.
     
  5. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Increase the array size, so you have more axis to edit:
    upload_2022-6-26_3-34-8.png

    Then just set the name and the rest of the data and it'll automatically show up as in the posted image.
     
  6. phildragon

    phildragon

    Joined:
    Apr 4, 2014
    Posts:
    9

    Attached Files:

  7. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    There's a folder "ProjectSettings" in the asset with a file called "InputManager.asset". You can copy this to your ProjectSettings folder and gives you a default setup for the controller. Doing so would overwrite the inputs you have already defined, so be aware.
     
  8. phildragon

    phildragon

    Joined:
    Apr 4, 2014
    Posts:
    9
    Oh okay I just got it. Increase the Axe size provide more data and by default they call it "Cancel". I see. I was able to manually add "Right_3", "Right_4" and "Right_5".
     
  9. phildragon

    phildragon

    Joined:
    Apr 4, 2014
    Posts:
    9
    Hi team,

    How guys you doing today?

    I have to be honest: this is the best concept of Third Person Controller I have ever seen.
    However, players only play with keyboard: they also play with GamePad.

    This image below shows what I want to do: [view file "objective.png"]

    Everything works fine for the keyboard. When I use the GamePad, I can only control the player, not the Camera. I also tried with the Project Settings (InputManager) that you proposed, it doesn't do what I want but to be in some interesting path. From InputManager I added another "Mouse X" and "Mouse Y" but for the GamePad instead of the mouse. View image below [view file "axis.png"] (Note that I create an empty Unity Project and import "THOMAS ENZENEBNER Third Person Camera 1.0.7.2" from Asset Store).

    It almost worked except that the camera keeps moving around. I kept moving slowly. Maybe it's my computer which weird.

    Any suggestions?

    Thanks for your attention.

    Phil.
     

    Attached Files:

  10. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Have you added the "CameraInputSampling_FreeForm" component?

    As you mentioned Mouse works for you I guess you already did.
    This component also supports controllers when the "Controller Enabled" flag is ticked. (default is false) It then samples, much like the mouse does for Mouse X/ Mouse Y, the axis Right 3/4/5, dependent on the platform. (I'm testing this myself with a Xbox controller)

    upload_2022-7-6_4-44-49.png

    Unless you get the warning: "Controller Error - Right axis not set in InputManager. Controller is disabled!" - this should work when the Right 3/4/5 axis are setup like I've shown in the previous post.
     
  11. phildragon

    phildragon

    Joined:
    Apr 4, 2014
    Posts:
    9
    Oh WOW! Yes, I just tried what you did and it works. Now I can continue working on my project. Thank you so much Enzi! You make my day! :)
     
    Enzi likes this.
  12. phildragon

    phildragon

    Joined:
    Apr 4, 2014
    Posts:
    9
    Hi, about the AIThirdPersonController. I was working well in the old version (Unity 5) , now, I don't konw if it's me who didn't select the correct paramters or else, but when I put this floor static and also baking it, I add the AIThirdPersonController and I made the player is target, the ew character is not walking. He moves forward thanks to the navmesh but it jams. Any suggestion please?

    I create a public folder in my Google Drive for sharing a video I made:
    https://drive.google.com/drive/folders/1lKT7P3KCm0NRaW6eEwvlpyzPWDVNa9pp?usp=sharing
     
  13. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Please understand that I can only give support for the asset and camera itself. Any scripts related to demoing the asset are not included, so questions regarding AI, Navmesh, etc... are better suited in a separate forum post or Discord.

    That said, as the character seems to transition to a falling state, I think what's happening is that the CharacterController takes control and the AIController for moving the GameObject around the NavMesh is putting the GameObject slightly above the plane. To fix that, you can remove the CharacterController from your NPCs.
     
    phildragon likes this.
  14. phildragon

    phildragon

    Joined:
    Apr 4, 2014
    Posts:
    9
    Understood. Thanks for taking your time to answer. I appreciate it.
     
    Enzi likes this.
  15. heymickdoc

    heymickdoc

    Joined:
    Apr 11, 2022
    Posts:
    2
    Hi Enzi, I can't get it to work with the new Unity Input system... is there a switch I am missing or do I have to edit the supplied scripts manually?

    Ta

    Mick
     
  16. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Hey Mick!

    The provided input sampling scripts are only built for the old input system but the scripts are designed so the new input system can be easily integrated.

    FreeForm, LockOn and Shoulder work with an input struct and have a UpdateInput(InputStruct) method.
    So you can sample with the new input system, set these structs and then call UpdateInput with them.
     
  17. heymickdoc

    heymickdoc

    Joined:
    Apr 11, 2022
    Posts:
    2
    Thanks for the quick reply.

    I had a look through the FreeForm script and it seems fairly straightforward to update but I wanted to make sure that I didn't end up going to the trouble of creating it if you had a simple boolean flag or something :)
     
  18. phildragon

    phildragon

    Joined:
    Apr 4, 2014
    Posts:
    9
    I have one last question (no more after this one) and it's a bonus one: like it's not the end of the world if there is no answer for this questions.

    Here there way to moving the camera from the keyboard instead of the mouse?
    My intention is to use the I, J, K and L keys for moving the camera.

    I look at the "Camera Input Sampling_Free Form" component from the Inspector, I found what I put in the attachment, but I wasn't able to do what I want to do.
    Is there a solution?
    Thanks for your attention.
    Greetings.
     

    Attached Files:

  19. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Hey!

    Yeah sure, actually an oversight, to not support the keyboard. Kind of rare but why not.
    I'll send you an updated script. I think I still have your gmail.
     
  20. Filliy1

    Filliy1

    Joined:
    Nov 29, 2022
    Posts:
    1
    Hey, great job! Is there any way it works on mobile? I need this camera for WoW. I want to read more about that. But playing World of Warcraft you need to be able to buy game gold. It can really boost your skills in the game
     
  21. macube

    macube

    Joined:
    Jul 16, 2017
    Posts:
    37
    Hey,
    thanks for the Asset. Everything works except for one thing: the camera rotation with right Stick on Gamepad don't work. With Mouse-Movement it works... and all other things (like jumping etc.) works with gamepad too, but only the camera rotation with right stick not... I don't know why ?

    I'm use Unity 2021 LTS
     
  22. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Can you take a look at this post? LINK

    I think that should help, otherwise feel free to ask here or via email.
     
  23. macube

    macube

    Joined:
    Jul 16, 2017
    Posts:
    37
    yes, i have already do this, but don't work too... hmm..
     

    Attached Files:

  24. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Hm, so the only thing I can think of is that the wrong axis is sampled then. Which platform and controller are you using? The axis change for Windows/Mac/Linux.

    I also list of all other possibilities.
    Controller Enabled has to be enabled on starting the game.
    Axis are tested on Start. If it fails the warning

    Controller Error - Right axis not set in InputManager. Controller is disabled!
    shows up.

    If nothing works still, test which axis are responding to your right stick. 3rd/4th/5th or maybe another.
    Then set the Axis accordingly in the Input Manager. As long as the Name of the axis like Right_3/4/5 is still the same the asset will pick it up.
     
  25. macube

    macube

    Joined:
    Jul 16, 2017
    Posts:
    37
    Thanks, it works now, my mistake :) ;)
     
    Enzi likes this.
  26. JNeul

    JNeul

    Joined:
    May 11, 2016
    Posts:
    4
    Hi there, i'm looking to how to toggle between 1st person and 3rd person mode?
     
  27. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    There is no toggle method but switching from 3rd to 1st person is just a matter of setting the CameraController 'Desired Distance' to 0 and back again to the distance you want for the 3rd person. If you need help with the code I can post a snippet.
     
  28. JNeul

    JNeul

    Joined:
    May 11, 2016
    Posts:
    4
    figured it out set the distance in camera controller to toggled to zero / 2.5f, thank you
     
  29. unity_028AE3B1F1BC5DECE8AD

    unity_028AE3B1F1BC5DECE8AD

    Joined:
    Jul 31, 2022
    Posts:
    83
    Hello, for some reason the camera isn't following any target. Even in the demo scenes, the camera just stays stationary and doesn't follow? I've imported the asset fresh twice and it's the same thing, with no error messages given. As I said, this is strangely the case even in the demo scenes, so I'm not sure if I am missing some kind of dependencies. Hard to debug as no errors are thrown. The documentation doesn't say much about troubleshooting so I have no idea why this is the case. Any idea?
     
  30. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Hello!
    Sorry this is happening! This is the first time I'm hearing this.
    Are you importing the asset in an established project or a new one? Does it work for you in a fresh project?

    Can you send me screenshots of the CameraController component and hierarchy? The more details the better.
    You can do that either here or via mail.

    Thanks!
     
  31. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Hello, were you able to solve it?
     
  32. unity_028AE3B1F1BC5DECE8AD

    unity_028AE3B1F1BC5DECE8AD

    Joined:
    Jul 31, 2022
    Posts:
    83
    Hello, yes I managed to solve the issue. I responded however it seems the post has disappeared for some reason which is strange.

    My game assigns the cameras target manually so the cameras target starts as null. I put a random object in the target and then re-assign the player and for some reason it started working. Not sure why exactly, but it works, so that's good. I assume maybe the camera needs to start with the target as something to work correctly perhaps, as it seemed for me if it starts empty and then you manually assign it after initialization it does not work correctly.

    Great camera asset also, and thank you for taking the time to reply!
     
  33. ironfiftynine

    ironfiftynine

    Joined:
    Jan 22, 2013
    Posts:
    69
    Good day. Thank you for this Unity package as this can help me focus on other parts of our game. I'm posting here to consult about the issue that I am encountering. Please refer to this video below:



    I added some debug wire spheres to your camera controller code for a more intuitive interface. As you can see, my player is situated beside a wall. If you take a look at 00:07, my camera is viewing a wall that completely covers the player. I tried to understand the cause of this and as far as what I have learned from your code, your spherecast returns a hit point of zero vector because it overlaps with the collider of the wall so the occlusion doesn't trigger. So what I did was I adjusted the collision distance so that the hit point will be valid. This solves the case for the wall that covers the player.

    However, at 00:59, you can see that another issue popped up wherein the view gets occluded even though I can see the entire player on the camera if I disable the Occlusion check. This was the consequence of my adjustment of the collision distance. I figured I can fix this issue by adjusting the Max Thickness property (01:12). After I did this, the issue mentioned in the previous paragraph has re-occurred because the computed thickness became 0.

    I would like to ask if there is a way that I can fix both of the mentioned issues. Thank you very much.
     
  34. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Good day to you too! :)

    Some things I'm seeing, the near clip is a bit too high. You can set it to the min value of 0.001.This will reduce near clipping on very small scales scenes. There's really no downside of having a low near value.

    The collision distance has to be in relation to the player collider. The player collider seems to be a small capsule. Radius 0.5? The collision distance has to be lower than the capsule radius. Something like half the capsule radius should be a good value. For a 0.5 capsule radius, 0.1 - 0.25 works quite well.

    Also, I can see you have set the player layer to CameraFollow. Is that the same layer of the capsule collider of your player? If not, make sure the correct player layer is set. (The same layer the player collider uses)

    Let me know if this helps.
    In case it doesn't and it's possible for you, you can send me the project (or a reduced version) and I can take a look at it.
     
    Last edited: Jun 17, 2023
    ironfiftynine likes this.
  35. ironfiftynine

    ironfiftynine

    Joined:
    Jan 22, 2013
    Posts:
    69
    Thank you very much for your prompt response and my apologies for my late response. I wrote some code to adjust the collision distance to be 50% of the capsule collider's radius as you have suggested. I also adjusted the near clip (min is 0.01 and not 0.001 as far as I have checked). So far, I found some ways to tweak the behavior of the camera for the case that I presented. Currently, having the blocking collider beside the player is more sensitive compared to cases wherein the blocking collider is behind or in front of the player but I will settle for this for now until I am instructed to tweak this further.

    Thanks for the help! :)
     
  36. ironfiftynine

    ironfiftynine

    Joined:
    Jan 22, 2013
    Posts:
    69
    Good day. It's me again. I have another question. I would need to implement a specific behavior for the camera wherein the camera should not show (at any zoom distance) what is underneath the water mesh. The idea that I came up with is to use a spherical collider to determine whether the camera touches the water surface. However, this is not in synch with how the CameraController calculates the position of the camera since this happens at FixedUpdate so my idea won't work. So I would like to ask if there is a feasible way to do this. Thank you.
     
  37. Lunarthewolf

    Lunarthewolf

    Joined:
    Feb 10, 2019
    Posts:
    10
    On line 238 of CameraInputSampling_FreeForm.cs, I'm getting a compilation error for Linux target: "lockMouseCursor does not exist in current context". I'm guessing this is supposed to be lockAndHideMouseCursor?
     
  38. kidmethuselah

    kidmethuselah

    Joined:
    Jan 14, 2021
    Posts:
    16
    Is there anything glaringly obvious I'm doing wrong here?

    https://i.imgur.com/5zSJqG9.png



    When I first set it up I utilized occlusion check. Now I've decided (late into development!) I don't want to use the occlusion feature. When removed, the camera just passes through all objects. Seems it was only "working" before because collisions also count as occlusions, which makes sense.

    I've read through this thread and general advice seems to be to make sure the player layer and collision layer are set correctly, which it seems mine are.

    Things I've tried:

    1. Adding a a collider on the target object and/or the camera. Have added temporarily and it doesn't seem to make any difference.
    2. Its because I'm not following the parent object of the player. However, I don't see why that should matter as for generally boring reasons I HAVE to follow a child of the parent in this particular setup. Also, changing the target to the player parent makes no difference to the camera collision

    Any ideas? Would hugely appreciate any ideas you could throw my way.
     
  39. Dave_3Dln

    Dave_3Dln

    Joined:
    Aug 7, 2019
    Posts:
    1
    Is there a way to turn off targeting if the player is not near the target?
     
  40. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    There's currently no way for targets to be discarded as the expectation is that available targets will be managed via the Add/RemoveTarget method.
    However, a distance check can be added quite easily in LockOnTarget.cs around line 181 where TargetableWithDistance is added to the items list. Based on the distance you can skip that Add.

    As the LockOn feature still needs some management: A sphere trigger (or something fitting) around the player which will Add/Remove targets is the most performant and reliable way.
     
    Dave_3Dln likes this.
  41. Raikage46

    Raikage46

    Joined:
    Feb 17, 2019
    Posts:
    8
    Hi, I just bought the asset and so far I like it a lot! It's much better than what I had previously.
    I have one issue though: I don't seem to be able to get the Lock-On-Targeting to work. I added the Targetable script to my enemy character, I added the Lock On Target script and Camera Input Sampling_Lock On script to the camera. I also added an additional keyboard input for locking on. But when I press that or use the mouse button while my player character is close to the enemy, nothing happens.
    Do you know what might be the reason for this? Is there a step I missed?
     
  42. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Hey and thanks! :)
    I've screwed up some logic regarding LockOnTarget with CameraMode.Always. Maybe you were running into this problem because the rest of the setup looks correct to me.
    I've made the following changes:
    Code (CSharp):
    1. 1.0.7.3
    2.     - removed disable time from LockOnTarget
    3.     - fixed LockOn with CameraMode set to Always
    4.     - Added HandleLockOnTargets script which will automatically add/remove targets
    5.       For setup: Add HandleLockOnTargets and a Sphere Collider with 'Is Trigger' enabled to the
    6.       target or player. Also set the radius accordingly.
    This version can be downloaded here: http://www.enzenebner.com/beta with your invoice number, starting with INxxxxx. Put only the numbers in the field

    I've pinged you too for this update because the HandleLockOnTargets could help you.
     
    Dave_3Dln likes this.
  43. Raikage46

    Raikage46

    Joined:
    Feb 17, 2019
    Posts:
    8
    Thank you very much! Target-Lock-On now works in my project! :)
    Though I do have two other questions now...
    1. Is it possible to do the lock-on-check not only OnTriggerEnter and Exit but in Update? I'd like to stop locking onto an enemy the moment its HP reaches 0.
    2. Is there any way to go about this without the sphere collider? My enemies become Ragdolls when they are defeated, which means the sphere collider becomes capable of pushing away the bodies.
     
  44. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Great!

    1. You'd have to change the CameraInputLockOn struct and the "followingTarget" field to false when this happens. That way the lock on is released. Like this:
    Code (CSharp):
    1. LockOnTarget lockOnComp; // the enemy script needs access to it in some way
    2.  
    3. var input = lockOnComp.GetInput();
    4. input.followingTarget = false;
    5. lockOnComp.UpdateInput(input);
    6.  
    2. The sphere collider is a trigger so it can't push anything around. Does that happen for you?
     
  45. Raikage46

    Raikage46

    Joined:
    Feb 17, 2019
    Posts:
    8
    Sorry for the very late reply!
    1. It works now! Thank you so much!!
    2. I think I must have had another collider on my character... the camera isn't pushing anything, my bad.

    Again, thanks a lot for your help. I really appreciate that you take your time to help folks out here!
     
    Enzi likes this.
  46. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Hey, great to hear! Thanks for letting me know. <3