Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by delorean225 · Jun 22, 2014 at 01:44 AM · rotationmovementthird-person

Third Person Character Controller Movement

Alright, this is sort of a two part question, so be ready if you plan to answer it.

I want to make a third person shooter. I have made a character model, worked in some animations, etc., and now I have worked on control/camera. I have: -modified MouseOrbit to do my bidding -modified ThirdPersonController to move relative to the player due to the previous and now I want to make the player move left/right instead of rotating on a press of A/D.

I want to know, in essence: -What part of the code does the ThirdPersonController handle input? I can't figure it out. -How can I change the rotation to a movement along Vector3's left/right?

Thanks in advance.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image delorean225 · Jun 23, 2014 at 02:27 AM 0
Share

I guess not, then. No one replied.

avatar image DoctorMoney · Jun 23, 2014 at 03:39 AM 0
Share

I just took a look at it and it seems to have moveDirection involved which I never completely understood but that variable handles how things move and all.

You could try gameObject.transform.Translate (Vector3.Right); and left for left. That'll move it right and left

avatar image delorean225 · Jun 23, 2014 at 07:49 PM 0
Share

Thank you. I will look into that.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Erisat · Jun 23, 2014 at 03:53 AM

http://www.3dbuzz.com/training/view/3rd-person-character-system VERY high-quality tutorial series, walking through step by step making a very decent third person camera, character system. They go through all the theory step by step, and explain every little line of code in grave detail, no matter how simple it may seem. This is where I started, and I'm still using parts of it.

anyway, This is how i handle strafing:

if(myRigidbody.velocity.magnitude < MoveSpeed() && Grounded >= 1)

{

myRigidbody.AddForce(PlayerGO.transform.forward VAxis MoveSpeed());

myRigidbody.AddForce(PlayerGO.transform.right HAxis MoveSpeed());

}

where MoveSpeed() just returns a float of how fast you should move. example my strafing speed is 3f; HAxis and VAxis are just:

HAxis = Input.GetAxis("Horizontal");

VAxis = Input.GetAxis("Vertical");

anybody whos gone through that tutorial will probably see where i've used stuff from 3dbuzz, but ive changed it to be using physics forces instead of charactercontroller.move

The above assumes that your character has a rigidbody attached, and a collider of some sort. The Grounded >= 1 is just a check to see whether your colliding with the terrain. I've also used parts of faux gravity scripts, but thats not really relevant to the strafing portion.

If you don't want to use the physics rigidbody and instead want just the plain old charactercontroller component, then check this out: http://docs.unity3d.com/ScriptReference/CharacterController.Move.html

you can see the line

moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

the vector3 is (x,y,z), where x y and z are float values being fed by the keyboard input. x axis being left(negative) and right (positive), y being up(positive) and down(negative), and z being forward(positive) and backward (negative). this vector is then fed to charactercontroller.move, where it actually does the movement, Time.deltaTime makes sure that you move at a constant pace over time.

hope this helps

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image delorean225 · Jun 23, 2014 at 07:49 PM 0
Share

Thank you! It looks like I'll need to do some investigating into a custom character controller... Or maybe I'll rewrite the default? Who knows.

avatar image felixfors · Jun 24, 2014 at 03:46 AM 0
Share

You could try out the premade character controller script from the unity Script Reference. http://docs.unity3d.com/ScriptReference/CharacterController.$$anonymous$$ove.html

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

CharacterController.move doesn't seem to move me horizontally 0 Answers

Objects not always Spawning At Correct Location 2 Answers

Player won't look in direction and travel at the same time? 2 Answers

How to make an object rotate to raycast hit from mouse? Unity 3D 1 Answer

made a ring collider from sphere colliders and a bar collider, but when animated the ring doesn't stay on bar 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges