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 L2P_SouL · Jun 17, 2016 at 07:52 PM · unity 52d gamecharactercontrollertopdown

2D Top down player won't move down

Here is the script I'm using I don't know why but he will not move down ... Up,Left and Right are no issue but down is apparently impossible I even tried (-Vector2.up * speed) still won't move down ... any help ??

using UnityEngine; using System.Collections;

public class PlayerController : MonoBehaviour { public float speed;

 // Use this for initialization
 void Start()
 {

 }

 // Update is called once per frame
 void Update()
 {

     if (Input.GetKey(KeyCode.D))
     {
         transform.Translate(Vector2.right * speed);
     }
     if (Input.GetKey(KeyCode.A))
     {
         transform.Translate(Vector2.left * speed);
     }
     if (Input.GetKey(KeyCode.W))
     { 
         transform.Translate(Vector2.up * speed);

      if (Input.GetKey(KeyCode.S))
      {
             transform.Translate(Vector2.down * speed);
         }
     
     }
 }

}

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 antiquote · Jun 17, 2016 at 08:04 PM 1
Share

Also I'd recommend using Physics2D or Rigidbody2D for your movement later on. Trust me, it'll serve you much better in the future. You're smart, I'm sure you're able to figure out how to use it.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by antiquote · Jun 17, 2016 at 08:02 PM

It seems you boxed in your down IF Statement with your up. Delete your second to last curly brace and move it up after your transform.Translate( Vector2.up * speed );

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

Answer by L2P_SouL · Jun 17, 2016 at 08:10 PM

Hahaha omg what a fail that was exactly what I did ahahaha thanks so much and I will keep that in mind ... still learning how to properly script so that should help thanks a bunch!!

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 antiquote · Jun 17, 2016 at 08:21 PM 0
Share

It is my pleasure. I've been in your position before and I know how it is. Although, please use the "Add Comment" button if you wish to comment. 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

101 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 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 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

top down 2d shooter direction of enemies 0 Answers

Teleport 2D Character on TriggerEnter 2 Answers

how to make Touch for move gameObject in axis x with unity 2d. 0 Answers

Want to instantiate Prefab in its parent. 1 Answer

characterController reference issue 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