Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 grey walker · May 21, 2011 at 07:49 AM · movementnavigationspaceflight

Smooth Space Flight Script

Hello everyone, my name is Grey Walker.

I am looking for a script or scripter capable of making Eve-like space navigation. More specifically like Battlestar Galactica Online.

the functions would be right clicking in any forward direction, the ship or player tilts towards the direction and moves in that direction. The ship does not stop.

the movement speed is determined by a gui slider, but the ship does not move to a point, only moves in that direction.

If you know of a script that would aid me in this, or are able to yourself, write such a script, i would be very appreciative, and would add you to the credentials of my game.

notes:

Right click to make ship tilt and move in that direction. A secondhand GUI slider determines the speed of the ship, from high speed, to a stop. The ship must slowly turn towards the direction.

If you need reference, i urge you to research the movement controls displayed in Battlestar galactica online, which was made in unity.

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 · May 21, 2011 at 08:10 AM 0
Share

Probably don't need a 17-word tag. As it says, separate up to 5 relevant words with comments.

avatar image Muzz5 · May 21, 2011 at 09:15 AM 1
Share

Try writing it yourself, and post what you come up with for us to improve.

avatar image Edy · May 21, 2011 at 11:02 AM 0
Share

I'd begin by setting up a simple rigidbody with no gravity (rigidbody.useGravity = false), then using forces for moving it on the scene (rigidbody.AddForceAtPosition). Rotation can be applied by rigidbody.AddTorque.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by supamigit · Mar 18, 2014 at 09:22 AM

This code will give the relevant movement and camera controls using double click to move and right click to rotate camera.. Only thing i would like is a bit better response to the position of the double click.. maybe also a faster rotate to response to the click..

anyways HEREs a beter starting point.. Thank FORCEX for this code

 var PlayerCamera : Transform;
 
 private var ThisTransform : Transform;
 
  
 
 var CameraOffset : Vector3 = Vector3(0,3,10);
 
 var CameraSpeed : int = 200;
 
  
 
 var yMinLimit = -90;
 
 var yMaxLimit = 90;
 
  
 
 private var MouseInput : Vector2;
 
 private var directionTurn : Vector3;
 
 private var singleClick : boolean = false;
 
 private var count : int;
 
 private var Turn : boolean;
 
 private var cTimer : float;
 
 var doubleClickTime : float = .5;
 
  
 
 function Start () {
 
 ThisTransform = transform;
 
     PlayerCamera.eulerAngles = Vector3(0, 0, 0);
 
     PlayerCamera.position = Vector3(ThisTransform.position.x, ThisTransform.position.y + CameraOffset.y, ThisTransform.position.z - CameraOffset.z);
 
 }
 
  
 
 function Update () {
 
  
 
 ThisTransform.Translate(Vector3.forward * 5 * Time.deltaTime);
 
  
 
     if(Input.GetMouseButtonDown(0)){
 
         var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
 
         singleClick = true;
 
         count ++;
 
     }
 
  
 
     if(singleClick == true){
 
         cTimer += Time.deltaTime;
 
         
 
         if(count >1){
 
             directionTurn = ray.direction * 500;
 
             Turn = true;
 
             singleClick = false;
 
             count = 0;
 
             cTimer = 0;
 
         }
 
     
 
         if(cTimer >= doubleClickTime){
 
             count = 0;
 
             singleClick = false;
 
             Turn = false;
 
             cTimer = 0;
 
         }
 
     }
 
  
 
         if(Turn){
 
             var Rotation = Quaternion.LookRotation(directionTurn - ThisTransform.position);
 
             ThisTransform.rotation = Quaternion.RotateTowards(ThisTransform.rotation, Rotation, Time.deltaTime * 20);
 
             ThisTransform.eulerAngles.z = 0;
 
         
 
             var targetDir = directionTurn - transform.position;
 
             var forward = transform.forward;
 
             var angle = Vector3.Angle(targetDir, forward);
 
         if(angle < 0.05){
 
             Turn = false;
 
         }
 
     }
 
 }
 
  
 
 function LateUpdate(){
 
 UpdateCamera();
 
 }
 
  
 
 function UpdateCamera () {
 
  
 
 var rot : Quaternion = Quaternion.Euler(MouseInput.y, MouseInput.x, 0);
 
 var pos : Vector3 = rot * Vector3(0.0, CameraOffset.y, -CameraOffset.z) + ThisTransform.position;
 
     
 
     if(Input.GetMouseButton(1)) {
 
         MouseInput.x += Input.GetAxis("Mouse X") * CameraSpeed * Time.deltaTime;
 
         MouseInput.y -= Input.GetAxis("Mouse Y") * CameraSpeed * Time.deltaTime;
 
         MouseInput.y = ClampAngle(MouseInput.y, yMinLimit, yMaxLimit);
 
     }
 
  
 
 PlayerCamera.position = pos;
 
 PlayerCamera.rotation = rot;
 
 }
 
  
 
 static function ClampAngle (angle : float, min : float, max : float) {
 
     if (angle < -360)
 
         angle += 360;
 
     if (angle > 360)
 
         angle -= 360;
 
     return Mathf.Clamp (angle, min, max);
 
 }
Comment
Add comment · Show 3 · 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 RookieCSharp · Apr 03, 2016 at 10:45 PM 0
Share

I tried this script in a game i'm designing and it comes up with this error:

Assets/Scripts/Player Scripts/Pilot Script.cs(184,60): error CS0100: The parameter name `NeedSomeGeneratorHere' is a duplicate

avatar image DroidifyDevs · Apr 04, 2016 at 12:11 AM 1
Share

That error can't possibly be from that script as there is no "NeedSomeGeneratorHere" in the script that was posted!

avatar image RookieCSharp DroidifyDevs · Apr 05, 2016 at 02:13 AM 0
Share

i know i looked through the entire script a dozen times over, and still a headache

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Space Flight Script 1 Answer

2d Space Flight Movement Script 1 Answer

How can I accelerate my Object to a maximum speed 1 Answer

How do I detect when an object is a certain distance from a point in order to activate an event? 2 Answers

Mouse Movement (Tracking) 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