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 /
This question was closed Mar 14, 2013 at 06:46 PM by Fattie for the following reason:

Problem is not reproducible or outdated

This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by BCU_Euden · Mar 14, 2013 at 09:09 AM · rotationphysicstransform

Applying force, rotation, physics and stable movement to objects.

I'm creating an asteroid Dodging game with the simple point of scoring points the more asteroids you dodge. I'm using the Unity standard to rotate my ship giving the illusion of banking however when I also apply movement to this the ship moves in the direction of the rotation i.e: when I bank left the ships position is moving parallel to the angle so if it is now angled left the ship will now move up and right(north east direction) the opposite if I bank right the ship will move north west (going up+y and left-x) which is not what I wish for. I would like my ship to bank left and right but stay on the same y position and only move left and right . My current movement code is below:

using UnityEngine; using System.Collections;

public class shuttleControl : MonoBehaviour {

 float speed = 50f;
 
 public float tiltAngle = 30.0F;
 public float smooth = 2.0F;
 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
     
     float h = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
     
     float tiltAroundZ = Input.GetAxis("Horizontal") * tiltAngle;
     
     Quaternion target = Quaternion.Euler(0, 0, tiltAroundZ);
     transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * smooth);
     transform.Translate(h,0,0);
 }

}

Adding to this I would like to add physics the ship itself and the asteroids that it comes in contact with, I would like the asteroids to simply bounce off the ship (it has shields and every bounce will lower them until no more shields in which case the next time it collides with an asteroid it will call the blow up animation and end the game- I will work on this part later when I have the basics of the game working) what would I need on both objects to create this effect? I tried adding a mesh collider to the ship with a rigidbody but for some reason that sends the ship crazy with a floating point error appearing stating: "Due to floating-point precision limitations. it is recommended to bring the world coordinates of the game object within a smaller range" and the X Y Z coordinates of the ship have gone into overdrive. (this happens also to the asteroid should I do the same thing.

Finally I would like to instantiate the asteroids as random positions relative to the ship but in visual range, vary the size and randomize the movement and rotation.

Any help would be appreciated. I've tried to explain as best I can, I can clarify if points seem unclear.

Thanks,

Euden

EDIT: Although an answer as to how to keep it on the same axis it appreciated I have come up with a temporary solution which is to allow the ship to tilt at all angles by including the vertical axis also. this however, does not solve the physics problem and I would prefer to be able to tilt left and go left only without changing my Y position at all so only x and z are affected etc.

Comment
Add comment · Show 3
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 BCU_Euden · Mar 14, 2013 at 06:18 PM 0
Share

I am using Unity's physics, so I am adding rigid body's to the ship and the asteroids which seem to be fine, its when I add a collider to either of them do I get the crazy movement. Neither of them are being animated the physics are strictly using unity's components.

avatar image robertbu · Mar 14, 2013 at 06:44 PM 1
Share

You are asking multiple questions here. You need to edit this post to a single question and then post your other question each with their own question. This is both the rule of site as well as a practical consideration. For example, I know the answer to some of your questions, but not all, so I'm unlikely to answer. Plus once a partial answer is posted, you are less likely to get any follow-up answers to any unanswered portions.

avatar image Fattie · Mar 14, 2013 at 06:46 PM 0
Share

please post a new single, simple question.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

11 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

Related Questions

Rotating child doesn't move parent Rigidbody? 1 Answer

How to rotate a rigidbody relative to another? 1 Answer

Separate child rotation 1 Answer

how to CORRECTLY position and rotate a gameobject in unity 2 Answers

How to stabilize angular motion (alignment) of hovering object? 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