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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[RELEASED] Game Camera: AAA camera solution

Discussion in 'Assets and Asset Store' started by reindeer-games, Jun 17, 2014.

  1. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    427
    Hi, I find a few problems :)
    1. Change camera mode is a awesome! But when I change it from RTS to RPG, the camera freeze for a second after the transition is done. How to avoid this?
    2. RPGConfig.DefaultAngleX isn't always using the best route. For example "-1" is good, but "1" may rotate the camera a whole round.
    3. How to set RPGConfig.DefaultAngleX in script?
     
  2. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, I just tested with the demos and I don't see any problems. You can look at file DummyDemo.cs how I switch between camera modes. Also you can tweak transition time, just click on CameraManager object and there are two values, TransitionSpeed and TransitionTimeMax.

    When it happens? You are talking about initial rotation when you start the game or the rotation is messed up when you rotate using touch input?

    Code (CSharp):
    1. var config = CameraManager.Instance.GetCameraMode().Configuration;
    2. config.SetFloat("Default", "DefaultAngleX", angle);
    3.  
     
  3. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    427
    Hi, I'm trying to repro the first one :)
    2. the script is simple and I record a gif about how the camera actually move.
    rotate.gif
    Code (CSharp):
    1. public class testGameCam : MonoBehaviour {
    2.  
    3.     // Use this for initialization
    4.     IEnumerator Start () {
    5.         yield return new WaitForSeconds(1f);
    6.         ToRPG(); // CameraMode: RTS -> RPG
    7.     }
    8.  
    9.     void ToRPG ()
    10.     {
    11.         RG_GameCamera.CameraManager.Instance.SetMode (RG_GameCamera.Modes.Type.RPG);
    12.     }
    13. }
    rtsCam.jpg rpgCam.jpg

    If RPGConfig.DefaultAngleX=-36, everything is fine.
    rotate-36.gif

     
    Last edited: Apr 29, 2015
  4. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    I see, it's the interpolation issue, it chooses always one direction, not the shortest one, I will investigate it. Thanks for the feedback.
     
  5. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    427
    Hi, about the first issue, I think the key is that what is gonna happen if player rotate the camera before the camera mode transition is done, and is that possible to ignore user input before it's done?

    In this gif I rotate the camera immediately when the camera mode switch to RPG mode, the camera shake heavily.
    rotateShake.gif


     
    Last edited: Apr 29, 2015
  6. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, I found some solutions for you:

    To disable input during transition, replace this code in CameraManager.LateUpdate:

    Code (CSharp):
    1. void LateUpdate()
    2. {
    3.     cameraModes[currModeType].PostUpdate();
    4.  
    5.     if (transition)
    6.     {
    7.         transition = oldModeTransform.Interpolate(UnityCamera, TransitionSpeed, TransitionTimeMax);
    8.  
    9.         if (!transition)
    10.         {
    11.             RG_GameCamera.Input.InputManager.Instance.EnableInputGroup(InputGroup.All, true);
    12.  
    13.             if (finishedCallbak != null)
    14.             {
    15.                 finishedCallbak();
    16.             }
    17.         }
    18.  
    19.         RG_GameCamera.Input.InputManager.Instance.EnableInputGroup(InputGroup.All, true);
    20.     }
    21.  
    22. ....
    23.  
    24.  
    To fix the RPG rotation, there is a variable in RPGCameraMode called activateTimeout, in method Activate() set it to 0.0f, it force to update the angle immediately on startup, otherwise it will wait some time before it happens.
     
  7. reocwolf

    reocwolf

    Joined:
    Aug 1, 2013
    Posts:
    182
    Hi, Im having an issue where the camera's clipping plane auto sets to 0.01 which makes weir shadow glitches appear on objects. Is there a way that I can just set it up to 0.03 without it changing back?

    Also mobile input is workin in 3rd person but not in RPG. Under the inputmanager I selected "Stick" as move input for RPG instead of waypoint. But it still does nothing.
    Nevermind. Got the mobile input working. But I still need to fix the clipping plane issue.
     
    Last edited: May 6, 2015
  8. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, thanks for using GameCamera!

    The near clipping plane can be changed, open the file CameraCollision.cs and in awake method replace the clip plane parameter with your value:

    Code (CSharp):
    1. unityCamera.nearClipPlane = 0.03f;
    I can put it to collision config in the update.
     
  9. reocwolf

    reocwolf

    Joined:
    Aug 1, 2013
    Posts:
    182
    Nice. Thank you.
     
  10. reocwolf

    reocwolf

    Joined:
    Aug 1, 2013
    Posts:
    182
    Hi again. So I'm using camera events to do a "security camera" effect. I set up the trigger event and place an empty object in the location from where i want the camera to look and then set my character as target to look at. It works sometimes but most times the camera doesn't actually positions itself in the location i set up, sometimes its way off. What should i do?
    Apparently you have to give the transition enough time for it to travel from one spot to another. For some reason I was thinking about it as if it was speed.

    Also is there a way to turn off the collision system without having to tag every obstacle? My game is using the RPG mode. Also I have done an event that switches to "interior" and it works fine but in my case I would like the camera to reset rotation behind the character. Because I can disable rotation but then it might stay in a wrong position.
     
    Last edited: May 8, 2015
  11. reocwolf

    reocwolf

    Joined:
    Aug 1, 2013
    Posts:
    182
    Another question. If you use the camera event look at, you can either set it up to restore in exit or time. If you don't it stays permanent. But if you do another look at trigger, that one will take over. Except that if you do a cam event that is not look at, it wont activate. Is there a way to change that?

    Like say I have a Look at event that switches the cam to the pos of a "security cam" in the end of a corridor and when u exit the corridor there's a room and also another corridor next to the one you just got out of. But the cam event for the other corridor is Config mode:"interior" instead of a "look at" event. Only that if you set up the look at to restore on exit it will switch to "Default" config and the "Interior" cam event wont work. If you don't set up the restore on exit, the look at event will remain and the "interior" event wont work either.
     
  12. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    1) The collision cannot be disabled temporarily, but this can be useful, I'll put it to next update.
    2) Camera reset is currently only on ThirdPersonCamera, I'll fix it for other modes as well.
    3) I see the problem, so you have this sequence:

    default camera -> look at event -> interior camera

    and it does not work, because it always go back to default camera, not interior camera.

    I'll look at the problem.
     
  13. reocwolf

    reocwolf

    Joined:
    Aug 1, 2013
    Posts:
    182
    Wow thanks! You're kinda the quickest most efficient dev here. lol
     
  14. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    427
    Hi, is that possible switch default camera mode for all cameras?
    I find this in doc, but what about the camera is not currently used?
    Code (CSharp):
    1. var cameraMode = CameraManager.Instance.GetCameraMode();
    2. cameraMode.SetCameraConfigMode("Default");
    What I wanna do...
    Code (CSharp):
    1. void OnInit(){
    2. var _rpgCameraMode; //how to get this?
    3. var _rtsCameraMode;
    4. _rpgCameraMode.SetCameraMode("config1"); //set as default
    5. _rtsCameraMode.SetCameraMode("config2");
    6. }
     
  15. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, that is not possible because other camera modes are deactivated and when you switch to other mode config is reset on activation to "Default". However you can easily change this, for example you can go to RTSCameraMode.cs class and in the method OnActivate change the "Default" to something else.

    I can put it also to new version I am just working on, add default configuration on start to config.

    Regards.
     
  16. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    427
    Awesome!Thank you :)
     
  17. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hello,

    a new version 1.1.11 was just uploaded to AssetStore, changes:
    • disabling collision in runtime:
      • Code (CSharp):
        1. CameraManager.Instance.GetCameraMode ().EnableCollision (false);
    • reseting camera for other modes RTS/RPG
      • Code (CSharp):
        1. CameraManager.Instance.GetCameraMode().Reset();
    • default configuration for each camera mode (in inspector of camera mode)
    • debug camera - a new free fly camera mode for debugging your game
    • event supporting different configuration when exiting look at trigger
    • bugfixes
     
  18. reocwolf

    reocwolf

    Joined:
    Aug 1, 2013
    Posts:
    182
    Awesome works perfect! Thank you! Best camera system ever!
     
  19. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    427
    Thank you! :D

    BTW: AssetStore may overwrite the config files, so please backup your own json files(RTSConfig.json, RPGConfig.json etc.) at /GameCamera/Resources/Config/.
    If you forget this step, no panic, find Git.
     
    Last edited: May 17, 2015
  20. DeanMarquette

    DeanMarquette

    Joined:
    Feb 10, 2015
    Posts:
    165
    Hello, I’m using the third person camera with mobile controller, a sort of snap back to position would be perfect! is there a way to have the camera auto rotate behind the player? So I could rotate the camera around to see the front of the character and when I let go the camera goes back to position behind the player. This would solve some issues for me. One being that after I rotate with a right side swipe then use thumb stick on the left my camera rotates up instead of moving forward. I have to either wait a second or move left thumb stick twice before I start walking instead of looking up. Anyway, I believe auto rotate back behind the character would fix that and the user won’t have to keep manually adjusting the camera position throughout the entire game.
     
  21. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, there is no way to auto-rotate in current version, but I can do it for the next release. How would you want to activate the rotate back? Automatically after timeout? I guess I can make an option with timeout and a public function for script activation.
     
  22. DeanMarquette

    DeanMarquette

    Joined:
    Feb 10, 2015
    Posts:
    165
    Auto timer would probably be the best bet I guess I would set to .01. But I was thinking more like consistently pulling to position behind the character. The camera only rotates when the user initializes the rotation but the camera as a pull back to original position.

    Hope you can release this update as soon as possible, I've made a few changes to the controller.cs that I know I'll loose on import. Don't want to duplicate to much work :) THANKS!
     
  23. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Okey, sounds good. If you want to avoid loosing changes after import I recommend to use one of the versioning systems like GIT or Mercurial over your project, you can keep track of your changes and never loose your work.
     
  24. DeanMarquette

    DeanMarquette

    Joined:
    Feb 10, 2015
    Posts:
    165
    Hi, can you checkout my game video here

    It shows, the rotation issue, I'm also having a zigzag while running issue. The zigzag is fixed if I make the mobile thumbstick smaller, it allows easier control for some reason. However, if I make the thumbstick smaller it causes the camera to look up instead of making the character walk after I rotate the camera.

     
    Nothnless likes this.
  25. Konstantin_Plashkevich

    Konstantin_Plashkevich

    Joined:
    Jan 31, 2015
    Posts:
    7
    Hi. i find a bug and solution. If you using playMaker curson will not hide. It will be blinding. You heve to disable playMaker GUI object in scene and cursor will hide.You shave to disable aotumatic placing playMker gui on scena in playMaler settings.
     
  26. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    I have just uploaded a new version of GameCamera 1.1.12. It contains 2 features, Autorotate back of ThirdPersonCamera, you can enable it in ThirdPersonMode inspector settings (not in config) and second feature is sensitivity for mobile stick, you can adjust it and remove the zig-zag issue.

    Let me know if you have any problems.
     
  27. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    427
    Hi, I'm trying to build a adventure game(like Limbo, Ori etc). I guess RPG mode is what I want since my character only need to move horizontally and jump. I copy the codes from ThirdPersonInput.cs to RPGInput.cs, but it fails :(
    Is there any other settings stop character controller from jumping?
    Code (CSharp):
    1.  if (MoveOption == MoveMethod.Stick)
    2.             {
    3.                 //
    4.                 // movement
    5.                 //
    6.                 var horizontal = InputWrapper.GetAxis("Horizontal");
    7.                 //var vertical = InputWrapper.GetAxis("Vertical"); //move horizontal only
    8.                 var vertical = 0f;
    9.                 var move = new Vector2(horizontal, vertical);
    10.                 padFilter.AddSample(move);
    11.  
    12.                 #region Let's JUMP in the RPG mode!
    13.                 print("Jump= "+InputWrapper.GetButton("Jump")); //debug jump state
    14.                 SetInput(inputs, InputType.Jump, InputWrapper.GetButton("Jump"));
    15.                 #endregion
    16.  
    17.                 SetInput(inputs, InputType.Move, padFilter.GetValue());
    18.             }
    UPDATE: I find something inside Player.FixedUpdate, but it doesn't work if set it to inputSource!= InputSource.AI, I guess there'are more codes/animates relate to inputSource.
    Code (CSharp):
    1. if (!inputManager.IsValid || inputSource != InputSource.Direct)
    2.                 return;
    Hmmm.. What's the difference between AI/Direct, why we can't jump in RPG mode?
    Maybe I should use RPGCamera+3rdPersonInput instead?

    UPDATE: I end up by using the new CustomInput, API is quite handy. But an issue is that CustomInput can not work with CharacterContronller prefab. After check codes, I find that if we disable Player.AutoInput(chkbox) as doc says, Player.cs will not call DetermineInputBasedOnCameraMode(), that makes inputSource = InputSource.Invalid(in Start()).
    So I tweak it a bit for now, maybe you can find a better way to fix it :)
    Code (CSharp):
    1. //Player.FixedUpdate(){
    2. //...
    3. if (AutoInput)
    4.             {
    5.                 DetermineInputBasedOnCameraMode();
    6.             }else{
    7.                 //!AutoInput = Custom input in my case.
    8.                 SetInput(InputSource.Direct);
    9.                 RG_GameCamera.Input.InputManager.Instance.SetInputPreset(InputPreset.Custom);
    10.             }
    11. //...
    12. //}
     
    Last edited: Jun 24, 2015
  28. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi!

    RPG mode with jumping wasn't really tested, I just made a quick test and it can be easily enabled, open AIController.cs and pass the jump input to the animation controller:

    Code (CSharp):
    1.  
    2.  
    3. var jump = inputManager.GetInput(InputType.Jump, false);
    4.  
    5. // use the values to move the character
    6. animController.Move(new AnimationController.Input
    7. {
    8.      camMove = moveVector,
    9.      inputMove = aimMoveVector,
    10.      smoothAimRotation = true,
    11.      aim = aim,
    12.      crouch = false,
    13.      jump = jump,
    14.      lookPos = lookPos,
    15.      die =  isDeath,
    16.      reset = reset,
    17. });
    18.  
    However there is one catch, the jumping is interrupted by NavMesh agent which tried to stick the character on the navmesh, I haven't found a solution for this yet but, if you don't need NavMesh you can safely uncomment macro in the beginning of the file:

    Code (CSharp):
    1.  
    2. // no pathfinding, character will go to mouse position directly without any path check
    3. #define NO_PATHFINDING
    4.  
    5. // using Unity navmesh pathfinding
    6. //#define USING_NAVMESH
    7.  
    After this the jumping works as expected, if you need NavMesh we will have to make a workaround like turning off the agent while the character is jumping (or on timeout).

    Hope it helps.
     
  29. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    427
    Hi, I'm using the 3rd person controller and find that AnimationController.lookTarget can't be access from script and inspector, though it's public.
    I'm not good at this part so I insert a [SerializeField] tag before it. You may wanna have a look :)
    Cheers!
     
  30. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Thanks, noted! :)
     
  31. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    427
  32. MadMimic

    MadMimic

    Joined:
    Jan 23, 2013
    Posts:
    10
    Hello!

    Is it supporting windows store? I'm having trouble building for it.
    It works fine targeting windows phone 8 though.

    Assets\Packages\GameCamera\Scripts\Utils\IOUtils.cs(34,37): error CS0246: The type or namespace name 'DirectoryInfo' could not be found (are you missing a using directive or an assembly reference?)
     
  33. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, it does, looks like a bug in IO object, please take the file from attachment and overwrite file in GameCamera/Scripts/Utils/IOUtils.cs

    I'll put it to the next update.
     

    Attached Files:

  34. MadMimic

    MadMimic

    Joined:
    Jan 23, 2013
    Posts:
    10
    It didn't work, i´m sending a screenshot. test.jpg
     
  35. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Sorry, I forgot to hide the function parameter with unsupported type, please try again.
     

    Attached Files:

  36. MadMimic

    MadMimic

    Joined:
    Jan 23, 2013
    Posts:
    10
    Hello, it worked!

    I had to comment some GetType on 3rd/MiniJSON.cs and for some reason, the pinch zoom doesn't work, but I don't think it's a Game Camera problem.

    Anyway, thanks for your help! :)
     
  37. JeffG

    JeffG

    Joined:
    Oct 21, 2013
    Posts:
    74
    Love the controller. I replace another asset that attempted the same thing, but that didn't actually do the job required. (Bad performance and bad camera collision) This one works exactly how I would expect it

    Only 1 minor complaint. The default near plane clip of 0.01 was making the shadow system creates lots of weird artifacts on my terrain. Setting it to 0.1 cleaned everything up.
     
  38. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Thanks for feedback!
     
  39. PrismicStudios

    PrismicStudios

    Joined:
    Oct 31, 2013
    Posts:
    37
    Hi! I just purchased your asset and I really like it so far, but unfortunately I need my character absolutely centered in the game window. Using the 3rd person setting, using a dead zone of 0,0, It still seems as if there is a tiny dead zone and the player can move 5~10 percent of screen width in any direction. I've tried tweaking the scripts a little bit to force the camera's rotation to be absolutely pointed at the character (at least on the horizontal axis), but I didn't succeed. Where do I need to edit the code to have the player always dead center instead of lagging behind it a slight bit?
     
  40. PrismicStudios

    PrismicStudios

    Joined:
    Oct 31, 2013
    Posts:
    37
    Also, Although the camera is working, I'm getting this error, which is being called by a second instance of "GameCamera" that is created at runtime containing only a single disabled CameraManager:

    KeyNotFoundException: The given key was not present in the dictionary.
    System.Collections.Generic.Dictionary`2[RG_GameCamera.Modes.Type,RG_GameCamera.Modes.CameraMode].get_Item (Type key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
    RG_GameCamera.CameraManager.SetMode (Type cameraMode) (at Assets/GameCamera/Scripts/CameraManager.cs:86)
    RG_GameCamera.CameraManager.Awake () (at Assets/GameCamera/Scripts/CameraManager.cs:254)
    UnityEngine.GameObject:AddComponent()
    RG_GameCamera.Utils.CameraInstance:CreateInstance(String) (at Assets/GameCamera/Scripts/Utils/CameraInstance.cs:53)
    RG_GameCamera.CameraManager:get_Instance() (at Assets/GameCamera/Scripts/CameraManager.cs:26)
    RG_GameCamera.CollisionSystem.CameraCollision:Awake() (at Assets/GameCamera/Scripts/CollisionSystem/CameraCollision.cs:34)
    UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
    GameDataManager:OnLevelWasLoaded(Int32) (at Assets/Scripts/GameDataManager.cs:137)

    If it helps I'm instantiating the camera together with the character when I load level 1.
     
  41. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi

    thanks for using GameCamera!

    for fix the error, open file Assets/GameCamera/Scripts/CollisionSystem/CameraCollision.cs

    and move 2 lines from Awake():

    Code (CSharp):
    1. unityCamera = CameraManager.Instance.UnityCamera;
    2. Utils.Debug.Assert(unityCamera);
    3.  
    to Start()

    Code (CSharp):
    1. void Start()
    2. {
    3.     unityCamera = CameraManager.Instance.UnityCamera;
    4.     Utils.Debug.Assert(unityCamera);
    5.     unityCamera.nearClipPlane = config.GetFloat("NearClipPlane");
    6. }
    7.  
    Let me know if it helps.

    2) Also don't forget set spring to 0, I just tried this settings with the demo and it seems to be working well, even when I move my character a bit it always move the camera:

    3rdsettings.jpg
     
  42. PrismicStudios

    PrismicStudios

    Joined:
    Oct 31, 2013
    Posts:
    37
    Excellent! The error is fixed, however, even with your settings the camera's movement still lags behind the character's movement a little bit.
    Look at the mouse compared to the character:
    http://gfycat.com/UnacceptableLeanCats

    But I fixed it by changing this code in the ThirdPersonCameraMode script

    Code (CSharp):
    1. targetPos = targetFilter.GetValue();
    to this

    Code (CSharp):
    1. float y = targetFilter.GetValue().y;
    2. targetPos = Target.position;
    3. targetPos.y = y;

    Now I can turn the spring up on the jump!!
     
  43. PrismicStudios

    PrismicStudios

    Joined:
    Oct 31, 2013
    Posts:
    37
    and also this in the else in the Apply Spring function:

    Code (CSharp):
    1.  
    2. Vector3 smoothTarget = Vector3.SmoothDamp(targetPos, targetFilter.GetValue(), ref springVelocity, config.GetFloat("Spring"));
    3. targetPos = Target.position;
    4. targetPos.y = smoothTarget.y;
    5.  
     
    Last edited: Jul 14, 2015
  44. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    427
    Hi, I'm using the mobile control and meet issues.
    1. [SLOVED]How to set a button hideGUI in script? I failed like this.
    Code (CSharp):
    1. var _controlls = RG_GameCamera.Input.Mobile.MobileControls.Instance.Serialize ();
    2.         object _fireButton = null;
    3.         _controlls.TryGetValue ("Fire", out _fireButton);
    4.         if (_fireButton != null) {
    5.             (_fireButton as BaseControl).HideGUI = !enable;
    6.         }
    2. It looks that mobile button's "preserve texture ratio" property doesn't work well. I have several circle icons and they change to different kinds of ovals depends on the screen aspect.
    3. [SLOVED]When I use mobile controls, it's always move both on horizontal/vertical direction and can't move only in 1 direction.

    UPDATE: For people who stuck in issue 1, use this instead
    Code (CSharp):
    1. public void EnableButtonGUI (bool enable)
    2.     {
    3.         var _controls = RG_GameCamera.Input.Mobile.MobileControls.Instance.GetControls ();
    4.         BaseControl _button = FindMobileControl (_controls, "Fire"); //that button name you set in inspector
    5.         if (_button != null) {
    6.             _button.HideGUI = !enable;
    7.         }
    8.     }
    9.  
    10.     BaseControl FindMobileControl (BaseControl[] controls, string targetName)
    11.     {
    12.         if (!mobileControls.enabled) {
    13.             return null;
    14.         }
    15.         foreach (BaseControl item in controls) {
    16.             if (item.InputKey0 == targetName) {
    17.                 return item;
    18.             }
    19.         }
    20.         return null;
    21.     }
    22.  
    UPDATE: For issue3, I thought the axis value is relate-to the distance between our finger and center of the stick(circle). After tests, the key turns to be the circle radius, so if you suffer from this problem, make that circle bigger.
     
    Last edited: Jul 20, 2015
  45. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    thanks for the feedback, I'll update the asset:

    1) I will add public API to call that directly
    2) looks like a bug, I will test it
    3) I don't understand this so much, it's about the stick when you move your character, can you explain more?
     
  46. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    427
    #2 seems relate to Button.Size. When I use a rectangle texture on a 1080p screen, its width may 10px shorter than normal but I have no idea how come it's possible since the code looks very clean and reasonable.

    #3 Draw a picture to explain that, I'll take a further look later(currently I have to commit my game :) )
    stick circle.png

    Another problem is that I find the camera target on character may shake up and down heavily if device have performance problem(lower than 30fps I guess), is that normal?
     
    Last edited: Jul 20, 2015
  47. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Okey, I understand the problem of the circle. The shaking is not normal, it should take delta time into account when updating, I'll try to simulate it with low fps.
     
    zhuchun likes this.
  48. scourchesne

    scourchesne

    Joined:
    Aug 9, 2015
    Posts:
    1
    Hi and thanks for the high quality camera and controller.
    I'm just starting out with unity and I was wondering if someone could give me a few hints on how to get a character animator controller working with that 3rd person controller.

    I got the character to work with the standard animation of the 3rd person controller (run, jump, aim, crounch) but I need to get the character animation to work (melee attack...)

    The character is the Dwarf Warrior : https://www.assetstore.unity3d.com/en/#!/content/35294

    Regards
     
  49. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    427
    Hi, the shakeing problem looks relate to OnFallImpact, I'll dig further later on.
    Another thing confusing me is that I'm trying to write a "Dash" skill for player by add a value to velocity.x, but it doesn't move a bit when my character is onGround. I'd already cancel RigidbodyConstraints.FreezePositionX.
    So I take a look into AnimationContoller.OnAnimatorMove(),
    Code (CSharp):
    1.  
    2.             if (onGround && Time.deltaTime > 0)
    3.             {
    4.                 Vector3 v = (animator.deltaPosition * moveSpeedMultiplier) / Time.deltaTime;
    5.                 v.y = 0.0f;
    6.                 _rigid.velocity = v;
    7.             }
    If I comment this, character can dash onGround but it looks like "friction" has gone. Can you help? Thanks!
     
  50. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, thanks for using GameCamera!

    You can extend CharacterController with melee attack with this:

    First setup the melee input:
    1) In InputManager.cs enum add another InputType 'Melee'
    2) In ThirdPersonInput.cs on the end of UpdateInput(...) add
    SetInput(inputs, InputType.Melee, InputWrapper.GetButton("Melee"));
    3) In Unity input manager (access from Unity menu) add "Melee" input and map it to button you like

    Now setup the player input:
    4) Open Player.cs and somewhere in FixedUpdate() read the melee input
    var melee = inputManager.GetInput(InputType.Melee, false);
    5) Open AnimationController.cs and add "public bool melee" in the "Input" struct
    6) Back in Player.cs pass "melee" variable into Move function

    Now you have to extend the animation controller to play the melee animation:
    7) In AnimationController.cs locate method UpdateAnimator(), now you have to
    read the "input.melee" and set trigger in your animation tree to start the melee animation.
    If your animation tree is setup properly you shouldn't have any problems. There might be
    some edge cases like you don't want to trigger melee during jumping or aiming etc, but this
    will be very specific for your character.

    Let me know if you have more problems.