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 timo0060 · Jun 12, 2012 at 06:21 PM · 2djavascriptjumpingsidescroller

When I move my arms back and forth, the player stops falling or moves upward

So while I play my game, a 2D sidescroller, and I jump and move the arms from side to side, my player stops falling for a brief moment, or he goes up a bit. So I could in fact manage to fly in my game due to this bug. I would like this to be fixed. The arms have no colliders, only the body does. I use a character Controller, and if you need any code, be free to ask. If you don't quite get what I mean, here's a 30 second youtube video of my program so far can be found here . Thank you for all your help.

Bonus Question: I use "D" to move forward, and "A" to move back when my character is facing forward (nose is facing right). When my character changes direct (his nose faces left), D still moves it forward, and A moves it backward, but I want to switch the valuse. So if character is facing left, A is to go forward, and D is to go backwards. I hope that makes sense. But this a bonus question, so if you know a solution great, if not, please try to focus on the main problem. Thank you very much for your time.

Comment
Add comment · Show 7
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 timo0060 · Jun 13, 2012 at 01:31 PM 0
Share

Does any one have any ideas on a solution?

avatar image Sokco816 · Jun 13, 2012 at 04:44 PM 0
Share

Can you show your actual code? Its hard to see what the problem is without a snippet of the code. $$anonymous$$y guess would be that when you flip your character horizontally, you're not doing it in an efficient way.

avatar image timo0060 · Jun 13, 2012 at 11:53 PM 0
Share

The code you requested for me flipping my character around is this:

if(hitPoint.x > transform.position.x) // hitPoint is mouse position { forward = true; }

 if(hitPoint.x < transform.position.x)
 {
     forward = false;
 }
 

if(forward) //forward is true, I face right (forward in game world) { transform.eulerAngles = Vector3(0,0,0); }

if(!forward) // forward is false, I face left (backward in game world) { transform.eulerAngles = Vector3(0,180,0); }

avatar image torrente · Jun 14, 2012 at 12:13 AM 0
Share

Can you post up some more code? I am wondering if it has something to do with the movement code and not really the rotation. Also, are the other rotations drifting at all or do they stay at 0?

avatar image Sokco816 · Jun 14, 2012 at 12:19 AM 0
Share

Here, try two things. The bug is probably happening when hitPoint.x is equal to transform.position.x. So an easy fix would be change one of the equations(lets use the second) to

  hitPoint.x <= transform.position.x

Alternatively, if that doesn't work, there could be a weird bug with your eulerAngles thing. So ins$$anonymous$$d of

  transform.eulerAngles = Vector3(0,180,0); 

use

  transform.eulerAngles.y = 180;

Good luck on the project!

Show more comments

2 Replies

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

Answer by whydoidoit · Jun 15, 2012 at 11:56 PM

You need to remove this I think:

   moveDirection = transform.TransformDirection(moveDirection); //remove

Because that is changing your left right movement depending on the rotation of the character.

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 whydoidoit · Jun 15, 2012 at 11:57 PM 0
Share

I have to say I love the title of this post - but it does make think you've wired yourself up to some strange mechanism to control your game.

avatar image timo0060 · Jun 16, 2012 at 02:24 AM 0
Share

That worked, thank you very much. Also my apologies if the title was misleading or confusing. I also can assure you, it's a simple game with simple mechanics... So far.

avatar image
0

Answer by TahirG · Jun 13, 2012 at 11:05 PM

Its not your "arms". Your "arms" are only looking towards the target. How do you handle jumping? Did you make sure the character ca only jump if he's on the ground? You should be able to say something like:

 if (Grounded & Input.GetButtonDown("Jump"))
 // jump code here ......
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 timo0060 · Jun 13, 2012 at 11:53 PM 0
Share

$$anonymous$$y character can only jump when he's on the ground. In the video, I'm not moving up because I am hitting the jump button, it's because I'm turning, and when I do, I get that bug. Here's my turning around code:

if(hitPoint.x > transform.position.x) // hitPoint is mouse position { forward = true; }

 if(hitPoint.x < transform.position.x)
 {
     forward = false;
 }
 

if(forward) //forward is true, I face right (forward in game world) { transform.eulerAngles = Vector3(0,0,0); }

if(!forward) // forward is false, I face left (backward in game world) { transform.eulerAngles = Vector3(0,180,0); }

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

7 People are following this question.

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

Related Questions

How to make it so enemies only move towards the player when the player is colliding with an object 1 Answer

I am having issues with my Jumping Script. 2 Answers

Moving Player Up and Down in 2D 1 Answer

A node in a childnode? 1 Answer

Disabling the Z axis? 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