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 MrThunderizer · Jan 21, 2013 at 12:44 AM · javascriptmovementrestrictions

Restricting Movement To One Axis (Found solutions, but they didn't work)

I'd like to completely restrict movement on a specific axis since I am making a 2d game. After searching around it seemed that the two common fixes to this problem are:

  1. Use the rigid body constraints.

  2. Use the update function to change the axis position to zero.

Neither of these solutions worked for me, and i'm at a complete loss as to where I should even be investigating. Any ideas?

Thanks, Mark

Comment
Add comment · Show 6
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 Loius · Jan 21, 2013 at 12:47 AM 0
Share

In what way do those not work? Those are how you prevent rotation/movement.

avatar image NowhereStudios · Jan 21, 2013 at 12:48 AM 0
Share

What do you mean by restricting movement can you be more specific?

restricting a rigidbody animation or physics object?

avatar image MrThunderizer · Jan 21, 2013 at 12:48 AM 0
Share

Something that is probably worth mentioning is that I am attaching images to planes. I thought that maybe if I was to use cubes ins$$anonymous$$d that it would help, but it didn't...

avatar image MrThunderizer · Jan 21, 2013 at 12:54 AM 0
Share

It is a plane with a rigid body attached? and i'm not sure why they aren't working, but they definitely aren't. That's why this is so frustrating, I can't find one other person that's ever had a problem close to this.

avatar image MrThunderizer · Jan 21, 2013 at 01:06 AM 0
Share

I was thinking that maybe my problem has something to do with quaternions. I read that the rigid body constraints can be "overridden" pragmatically? So the physics engine might contradict what your script is telling the object to do.... Basically my problem is that my little ship (2d space shooter) goes hay wire, and it happens when I collide with other game objects.

Show more comments

2 Replies

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

Answer by NowhereStudios · Jan 21, 2013 at 02:41 AM

Ok,

First be sure that your box colliders have a Z scale = 1 (since you are using planes, still you must give a scale)

Then set both objects Z Position equal values.

Then finally on rigidbody, click on Freeze Position Z check to disable movement on Z.

PS: I assume that your camera is directed to Z-Axis.

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 MrThunderizer · Jan 21, 2013 at 04:39 AM

Well I wandered off and decided to work on my characters control while waiting for a response, and while doing that the problem somehow disappeared. Unfortunately I have no idea which one of my changes helped. The directions you gave is what I did initially. After that didn't work I attempted to use the update function to change it's position to zero every frame. So yea, i'll just hope that it doesn't reappear.

Thank you for such a clear response, and sorry that I forgot to mark the question.

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

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

12 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

Related Questions

How to move an object along the X and Z axis with arrow keys/wasd with javascript? 1 Answer

Player launches into air when hitting steep slopes 0 Answers

Make so the script only moves and makes actions to the gameObject that its attached to. 2 Answers

Enemy AI With changing Player 0 Answers

Movement script, moving up when moving positively in 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