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 /
avatar image
0
Question by Gameart1235 · Feb 07, 2016 at 03:00 AM · movementmovement scriptmove

Movement Help

Hello, I'm been trying to create a action game like movement.

So far I big doing a lot research on this, like from and so on. The way it look like to me that when you hit W your character move up and it rotation you up when you hit S it rotation the character down so he facing the camera and move down. The A and D key make the character turn that way and move that way. I script this and it worker good. the error come from when I'm trying to make the 45 angle one. like WD, WA, SA, SD, I can't come up with how the player slower rotation to that point.

By the way I'm using transform.eulerAngles to rotation the character and before that it check if( transform.eulerAngles.y != 90){ change transform.eulerAngles.y to 90;

PLZ HELP

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by mateo4632 · Feb 07, 2016 at 06:22 PM

I am working on a top down type of game to and I have the script for the player movement.

 using UnityEngine;
 using System.Collections;
 
 
 public class PlayerMovement : MonoBehaviour 
 {
     public float Speed = 15;
     public float RotSpeed = 180;
 
     void FixedUpdate()
     {
         //ROTATING
         Quaternion rot = transform.rotation;
         float z = rot.eulerAngles.z;
         z -= Input.GetAxis ("Horizontal") * RotSpeed * Time.deltaTime;
         rot = Quaternion.Euler (0, 0, z);
         transform.rotation = rot;
 
         //MOVING
         Vector3 pos = transform.position;
         Vector3 velocity = new Vector3(0, Input.GetAxis ("Vertical") * Speed * Time.deltaTime, 0);
         pos += rot * velocity;
         transform.position = pos;
     }
 }

Just add this to what you want to move and it should work. Let me know if this worked for you!

Comment
Add comment · Show 3 · 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 Gameart1235 · Feb 08, 2016 at 12:20 AM 0
Share

I try the script. Thank you by the way but it not what I'm looking for, the one that I need is one that when you hit the A key it turn the player left and then move the player in that way. but thank you for the help.

avatar image mateo4632 · Feb 08, 2016 at 05:13 AM 0
Share

@Gameart1235 so your looking for a grid type of movement? for example W key moves the player up and S moves him down, and then A turns the player 90 degrees counter clockwise and walks left, then D moves turns the player 90 degrees clockwise and moves to the right?

avatar image Gameart1235 mateo4632 · Feb 08, 2016 at 02:49 PM 0
Share

no, more like a action game. but I think I came up with something just need to do more research for it.

avatar image
0

Answer by SUpersindit2 · Feb 07, 2016 at 05:23 AM

I would assume that you want smoothing involved, consider using Mathf.SmoothDamp

Comment
Add comment · Show 1 · 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 Gameart1235 · Feb 08, 2016 at 12:24 AM 0
Share

I will try this thank you.

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

39 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Character rotates left and right instead of going forward. 1 Answer

Slowly move a GameObject on 1 axis, then destroy it. 1 Answer

New to Unity & Scripting, How Do I Create a Movement System Thats About Building Up Speed? 0 Answers

How to I put a speed limit on my character's movement? 1 Answer

Implementing Counter-Movement 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