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 Skyler_Hawkins · Aug 18, 2016 at 03:50 PM · c#2dmovementcontroller

Movement Problems PS4 Controller

I'm building a 2D platforming project and I started to expand the controls from just keyboard to PS4 controller and the only part I can not figure out is getting the axis (analogs sticks/directional buttons) to work with it. I have map my PS4 controller in the Input Manager, but is I am still running into a problem with using the "Horizontal" for my player movement. I believe this is a problem with my scripting, I have tried GetAxis and several other scripting found on the internet and the ones found in unity's 2D projects scripting and it gets me no where which makes me believe it's my scripting that is interfering with being able to use any of the PS4 axis inputs.

Here is my pieced together script that I have been using to move around and now stick on.

 using UnityEngine;
 using System.Collections;
 using UnityStandardAssets.CrossPlatformInput;
 
 
 public class PlayerController : MonoBehaviour
 {
 
     //Movement
     public float speed;
     public float jump;
     public bool candoublejump;
     public GameObject deathParticles;
     public GameObject JumpingParticles;
     public GameObject BigJumpingParticles;
     public int LiveCount;
     float moveVelocity;
     public Vector2 spawn;
     
 
 
     //Grounded Vars
     bool grounded = true;
     void start()
     {
         spawn = transform.position;
         
     }
 
     void Update()
     {
         //Jumping
         if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Joystick1Button1))
         {
             
             if (grounded)
             {
                 GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, jump);
                 Instantiate(JumpingParticles, transform.position, Quaternion.identity);
                 candoublejump = true;
                 print("jump!!");
             }
             else
             {
                 if (candoublejump)
                 {
                     candoublejump = false;
                     GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, jump);
                     Instantiate(BigJumpingParticles, transform.position, Quaternion.identity);
                 }
             }
         }
 
         moveVelocity = 0;
 
         //Left Right Movement
 
 
         if (Input.GetKey(KeyCode.LeftArrow))
         {
             moveVelocity = -speed;
         }
         if (Input.GetKey(KeyCode.RightArrow))
         {
             moveVelocity = speed;
         }
 
         GetComponent<Rigidbody2D>().velocity = new Vector2(moveVelocity, GetComponent<Rigidbody2D>().velocity.y);
        
     }
 
     
   
 
         //Check if Grounded
         void OnTriggerEnter2D()
 
     { 
             grounded = true;
             print("Grounded!!!!!");   
     }
 
     void OnTriggerExit2D()
     {
         grounded = false;
 
     }
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

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

Making a bubble level (not a game but work tool) 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Question on Sprite and Movement 0 Answers

Moving using controller stick question 1 Answer

Android 2D Character Controller 2 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