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 Dec 14, 2013 at 04:17 AM by Carbongrip for the following reason:

Closed by thread maker for outdated and overused

avatar image
0
Question by Carbongrip · Oct 26, 2013 at 11:18 PM · c#transformscenerotate

Unity 3d(Space) Questions

Hey everyone got some questions and yes I know Im total noob…

  1. How can I improve my ship movement script? It seems a bit buggy when turning for some reason almost like bending space but its ok I guess…also how can I tilt the ship slightly when turning? I am going for a STO style ship control system thing.

    using UnityEngine;

    using System.Collections;

    public class ShipControl : MonoBehaviour {

      public Transform ship;
         float flyingSpeed = 0;
         float turnSpeed = 50.0f;
     
         void Update ()
         {
             //Accelerate the ship using the thrust key.
     
             if(Input.GetKeyDown("e"))
             {
                 if(flyingSpeed == 0)
                 {
                     flyingSpeed = 2.5f;
                     ship.transform.Translate(0,-flyingSpeed * Time.deltaTime,0);
                 }
                 
                 if(flyingSpeed == 2.5f)
                 {
                     flyingSpeed = 5f;
                     ship.transform.Translate(0,-flyingSpeed * Time.deltaTime,0);
                 }
             }
     
             //Decelerate the ship using the thrust button.
     
             if(Input.GetKeyDown("q"))
             {
                 if(flyingSpeed == 5f)
                 {
                     flyingSpeed = 2.5f;
                 }
     
                 if(flyingSpeed == 2.5f)
                 {
                     flyingSpeed = 0;
                 }
             }
     
             if(Input.GetKey("w"))
             {
                 ship.transform.Rotate(20.0f * Time.deltaTime, 0.0f, 0.0f);
             }
     
             if(Input.GetKey("s"))
             {
                 ship.transform.Rotate(-20.0f * Time.deltaTime, 0.0f, 0.0f);
             }
     
             if(Input.GetKey("d"))
             {
                 ship.transform.Rotate(0.0f, turnSpeed * Time.deltaTime, 0.0f * Time.deltaTime, Space.World); //and then turn the plane
             }
     
             if(Input.GetKey("a"))
             {
                 ship.transform.Rotate(0.0f, -turnSpeed * Time.deltaTime, 0.0f * Time.deltaTime, Space.World); //and then turn the plane
             }
     
             ship.transform.Translate(0,-flyingSpeed * Time.deltaTime,0);
         }
     }
    
    
  2. Edit: Solved!

  3. Edit: Solved!

  4. Is there a way I can make two ships collide by just making a collision sphere on both that detect each other? I don't need all the fancy physics, using transform for movement currently.

Comment
Add comment · Show 1
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 Huacanacha · Nov 05, 2013 at 01:14 AM 0
Share

You should really start a new question as this one will get messy with all the updates... but for simple sphere collision check you can easily do this yourself:

 (obj1.transform.position - obj2.transform.position).magnitude < (obj1.colliderRadius + obj2.colliderRadius)

Where colliderRadius is whatever the sphere radius should be on each object.

1 Reply

  • Sort: 
avatar image
0

Answer by tanoshimi · Oct 27, 2013 at 07:25 AM

  1. Try http://alexcpeterson.com/spacescape

  2. Lots of possible approaches: simplest is to create a new sphere gameobject, use a semitransparent, emissive material (to give a "glow"), make it a child of your spaceship object and centre it by setting x,y,z translation to 0

  3. Yep - attach a sphere collider and rigidbody component to each ship, but select "is kinematic" because you'll be moving them yourself. Then you can write code that listens to the OnCollisionEnter () event

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 Carbongrip · Oct 27, 2013 at 04:48 PM 0
Share

I have a problem… I added a Ridgidbody to both ships and use is $$anonymous$$inematic, unchecked gravity, and set angular drag to zero for both ships. But now I have 999 actor errors saying "Actor::update$$anonymous$$assFromShapes:Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!" what on earth does this mean? I am not looking for physics such as inertia or drag or anything just need to check the collision of my ship I move with transform script.

Follow this Question

Answers Answers and Comments

16 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 avatar image avatar image avatar image avatar image

Related Questions

How i can equal 2 Tranform Rotations? 1 Answer

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

Multiple Cars not working 1 Answer

Implement the equation as a code? 1 Answer

Conceptual Question on Creating Arrays at Runtime 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