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

character motor

Discussion in 'Scripting' started by mrbdrm, Mar 28, 2011.

  1. mrbdrm

    mrbdrm

    Joined:
    Mar 22, 2009
    Posts:
    510
    Hello
    im serching for a character motor that doesn't have strafe i want rotate insted .
    the normal character motor dosn't rotate and the one from 3DPlatformTutorial , can't get it to work right also it have jump and wall jump and other thing that i don't use , any help ?
     
  2. mrbdrm

    mrbdrm

    Joined:
    Mar 22, 2009
    Posts:
    510
    no one will help :(
     
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,061
    And here is why no-one helps. Let's pick apart your post. I'll quote your post and then type my thoughts when I read it.

    Hi!
    Oh a typo, oh well I do those a lot myself.
    character motor? What is that?
    Oh maybe he means Character Controller?
    mmm another typo...
    Again with the motor thing, guess he really does mean Controller, but how is expecting people to understand what he wants if he doesn't look up how things are called first?
    Another typo, man this post was written in a hurry or something! Or he's really lazy...
    The who what now? Couldn't provide a link of what he's talking about? Maybe it's some tutorial unity provides? I will have to look that up myself I guess.
    So he has something that does more than he wants but he can't get it to work? Syntax is kind of hurting my brain... I guess he'll tell us what the error message he gets is.
    ....That's... It?

    Your post shows that you put little to no effort in writing it. What you want isn't clear and to even understand what you are saying requires me to make assumptions that I really don't want to make. Somehow I just lost all my motivation...
     
  4. Kokumo

    Kokumo

    Joined:
    Jul 23, 2010
    Posts:
    416
    AcidArrow, maybe mrbdrm can't speak english as well as you because he or she is not from EEUU, England or any other english speaker country (like me). So, please, be patient.

    mrbdrm, i think i understood what you said; there is a script which allow you to rotate an object when moving the mouse in a vertical or horizontal direction. I can't remember the name... but i'm sure someone will tell us.
     
  5. mrbdrm

    mrbdrm

    Joined:
    Mar 22, 2009
    Posts:
    510
    AcidArrow
    thank you for your kind words .
    yes its called character motor open unity and check it , i may have typos but at least i know what im talking about :)

    Kokumo
    Thanks , yes my main language is not English , changing how the camera behave sort of give me the rotation that i want .
     
    Last edited: Mar 29, 2011
  6. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,061
    My native language is not English either, so whatever.

    And the OP's post was a lazy one, even with language barriers and whatnot.
     
  7. Kokumo

    Kokumo

    Joined:
    Jul 23, 2010
    Posts:
    416
    I don't know if the script name is "lookat" or "mouselook" or something like this; i'm sure it is in the standard assets script folder.
    I'm not near a pc with Unity right now, so, you must wait until i reach home.
     
  8. jonbonazza

    jonbonazza

    Joined:
    Nov 6, 2010
    Posts:
    453
    I have said it many times and I will say it again. This forum is not a code repository. We provide help, not full implementations. Furthermore, this is such a trivial problem, therre is no reason you shouldn't be able to do this yourself. only minor changes need to be made to the CharacterMotor shipped with the standard assets to achieve the functionality you need.
     
  9. mrbdrm

    mrbdrm

    Joined:
    Mar 22, 2009
    Posts:
    510
    well i ask this because maybe someone else had the same need as me , also don't think im just standing here waiting for a script im trying to solve it with what i can .
     
  10. 2dfxman1

    2dfxman1

    Joined:
    Oct 6, 2010
    Posts:
    1,065
    Just make it so controller rotates when you press this or that in stead of strafing...
     
  11. Irishsun530

    Irishsun530

    Joined:
    Jun 23, 2012
    Posts:
    13
    I am having the exact same problem.

    I to am having the CharacterMotor.js, I switched computers a few weeks back and had it modified so it would rotate when I would hit 'A' (left arrow) or 'D' (right arrow). Now it reformatted itself to strafe again.

    I am by no means an expert but I was proud I figured it out before. Now I am just stumped.

    I am not sure if it involves moveDirection and the deltaTime.

    The script is 500 lines with explanations within so I really don't want to post the whole thing. Especially since I am uncertain of the exact part that needs fixed.

    Any suggests of something I need to look for to not allow it to strafe?

    Much Thanks.
     
  12. Jacksendary

    Jacksendary

    Joined:
    Jan 31, 2012
    Posts:
    408
    Very mature /golf-clap

    And you honestly don't know that there is something called character motor?

    there is 3 things you can do...

    1: customize the the current motor.
    2: Make your own (isn't to hard)
    3: "steal" others work, if you look up "BergzergArcade" on ggogle you'll fine a very well made unity C# guide for a hack'n'slash RPG and also try to look and unity3D's wiki site, LOTS of character controllers and motors there.
     
  13. Irishsun530

    Irishsun530

    Joined:
    Jun 23, 2012
    Posts:
    13
    @jackie0100 I have actually looked at the wiki.unity3D site and JavaScript - HeadLookController.js looks the most like what I may need and maybe also @AcidArrow.

    Because the CharacterMotor script is so long and complicated though if the HeadLookController is created in it's own .js script then added to the First Person controller (character) that wouldn't work because of the Mouse look and so forth (the basic setup given for FPS).

    Any suggestions. I will mess with it a bit but would be nice for a guide line.

    Thanks.
     
  14. StephaneB7

    StephaneB7

    Joined:
    Oct 23, 2012
    Posts:
    5
    I wished more information would have been provided within this thread, to help beginners. Since I have solved that problem, here are my modifications to allow the CharacterMotor to turn rather than strafe. I have converted CharacterMotor.js to C# but it should not be too difficult to adapt these modifications to original JavaScript code.

    Added the following property to CharacterMotor, just beneath inputMoveDirection:
    Code (csharp):
    1.  
    2. [System.NonSerialized]
    3. public float inputRotation = 0.0f;
    4.  
    Added a property to CharacterMotorMovement:
    Code (csharp):
    1.  
    2. public float rotationSpeed = 10.0f;
    3.  
    Created the following basic function. Note that it does not cover sliding, platforms nor jumps.
    Code (csharp):
    1.  
    2. private void ApplyInputRotationChange()
    3. {
    4.     if (canControl)
    5.     {
    6.         tr.Rotate(0, Time.deltaTime * inputRotation * movement.rotationSpeed, 0);
    7.     }
    8. }
    9.  
    Modified the Update() function by adding a call to ApplyInputRotationChange(), just below the call to ApplyInputVelocityChange()

    Finally, here's how I converted the input into a rotation. To keep the code clean, this snippet is within a separate class, and both the CaracterController and the InputController are added to the prefab.
    Code (csharp):
    1.  
    2. private void Update()
    3. {
    4.     var rotation = Input.GetAxis("Horizontal");
    5.     if (Mathf.Abs(rotation) > Mathf.Epsilon)
    6.     {
    7.         // Apply the rotation to the Motor
    8.         motor.inputRotation = rotation;
    9.     }
    10.     else
    11.     {
    12.         motor.inputRotation = 0.0f;
    13.     }
    14. }
    15.