Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by wiratamana · Apr 04, 2016 at 08:35 AM · c#character controllercamera rotate

help script c#

hey im a beginner in unity, and i tried to make an object with 3rd person view

i managed to make first character movement with asdw or arrow key

i make me happy because it was my first script hat can run perfectly

but, what i really want is to make a movement by pressing only W, and controlling the direction by pointing with mouse. its like skyrim controller.

and this the script im using now using UnityEngine; using System.Collections;

 public class NewBehaviourScript : MonoBehaviour {
  
     public float moveSpeed;
     public float turnSpeed;
     public float jumpSpeed = 8.0F;
     public float gravity = 20.0F;
     public bool grouded = true;
  
     void Start ()
     {
         moveSpeed = 3f;
         jumpSpeed = 8f;
     }
    
     void Update()
     {
         transform.Translate (moveSpeed * Input.GetAxis ("Horizontal") * Time.deltaTime, 0f, moveSpeed * Input.GetAxis ("Vertical") * Time.deltaTime);
         //transform.Rotate (Vector3.up, -turnSpeed * Time.deltaTime);
  
         if (Input.GetButtonDown ("Jump") && grouded == true)
         {
             transform.Translate (0f, jumpSpeed * Time.deltaTime, 0f);
             grouded = false;
             grouded = true;
         }
     }
  
  
 }

oh and i want to make jump script, but that jump script really strange. please helo

Comment
Add comment · Show 1
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 Fredex8 · Apr 04, 2016 at 11:40 PM 0
Share

Translate moves an object, it doesn't rotate it. You should be able to find a working script to rotate the character with the mouse easily enough anyway.

Your jump script is currently just going to move the player up by a tiny amount every time the jump key is pressed regardless of whether it is on the ground or not since you are setting 'grouded' to false then true in the same frame so it is never actually being changed.

You may want to have your player detect collisions with the ground to deter$$anonymous$$e when it can jump again. The jump movement might want to be done with a coroutine which would be started on pressing jump. Trying to use Translate with GetButtonDown is going to mean it only moves on that one frame in which the jump key was down and nothing else.

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

CharacterController issue: transform.positionWithLocalOffset assign attempt for 'Player' is not valid. positionWithLocalOffset is {NaN, NaN, NaN} 0 Answers

Faux Gravity Character Rotate Problem 0 Answers

2d character controller tutorial stuck while walking 0 Answers

Unity's FPC apply camera deadzone for mouse 0 Answers

Recognize when ever camera looks up and turns back down 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