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 zero_null · Jan 19, 2015 at 03:04 PM · thirdpersoncontroller

Need Help in Restricting Player Movement to Only 2 Axis,

I am creating a 2.5D Side Scrolling type Game. For the most part I am using a 3rd Person Character controller. The Major Problem that I am facing is how I can limit the motion of my Player Character to Just 2 Axis. I want to make a Fully Fledged Game so Climbing Ropes and Jumping Rocks etc everything will be there. I am not quite experienced with Unity. Although I have created few 2D. For the 3D World it’s Just a different Universe. There are Zillions of things out there on internet and I have researched allot and read, understood and done so many things to get my task done. But I am unable to achieve what I am looking for. I want my character controller to Use Mechanim, It is creating issues for me because almost All of the tutorials that I am focusing are Legacy Animation Oriented. Please Help me so I may proceed. I am not asking for spoon feeding and Kindly excuse me if I am doing wrong by posting.

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

1 Reply

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

Answer by Mmmpies · Jan 19, 2015 at 04:38 PM

In theory, as I don't program 2.5D games myself, you could just not bother moving the Z axis of the character.

 using UnityEngine;
 using System.Collections;
  
 private float mySpeed;
 private float jumpSpeed; 
  
 function Start () {
     mySpeed = 4.0f;
     jumpSpeed = 6.0f;
 }
  
  
 function Update () {
  
  
     if ( Input.GetKey(KeyCode.z) ) {
         transform.position.x -= mySpeed * Time.deltaTime;
     }
    
     if ( Input.GetKey(KeyCode.x) ) {
         transform.position.x += mySpeed * Time.deltaTime;
     }
 
     if ( InputGetKey(KeyCode.Space) ) {
         transform.position.y += jumpSpeed * Time.deltaTime;
     }
    
 }

Well that jump's pretty dodgy, you probably want to have a rigidbody and apply an upward force.

As for the mecanim, you probably just need to understand how to send bools to change the animation that's being played.

All of this is untested but hopefully will give you a starting point.

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 zero_null · Jan 19, 2015 at 06:25 PM 0
Share

I hope so. but atleast for now. I am not quite successful doing stuff.

avatar image Mmmpies · Jan 19, 2015 at 08:33 PM 1
Share

Had a quick look for some tutorials and found these:

2dGamesInUnity

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

Have I to disable the gravity to drag an object? 1 Answer

Third Person Controller Custom Characterstates 0 Answers

Third person controller not being destroyed although script works 1 Answer

How to disable the input for the ThirdPersonController/normal input when the player is writing in an InputField? 1 Answer

bizarre collision modulations with character controller 1 Answer


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