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 /
  • Help Room /
avatar image
0
Question by NoSaintNick · Dec 11, 2015 at 03:07 PM · script.controllercamera followspaceshipthirdpersoncontroller

Spaceship Script not working?

I watched an online tutorial on how to make a script for space flight controls. After I finish and saved the C# script and went back to unity it said I had numerous name space and phrasing errors? I'm pretty new to coding all together and I've been trying to find the solution for 2 days now with no luck. This is the script I am using bellow:

var turnspeed = 6.0; var speed = 10.0; private var trueSpeed = 0.0; var strafeSpeed = 5.0; function Update () { var roll = Input.GetAxis("Roll"); var pitch = Input.GetAxis("Pitch"); var yaw = Input.GetAxis("Yaw"); var strafe = Vector3(Input.GetAxis("Horizontal")*strafeSpeed*Time.deltaTime, Input.GetAxis("Vertical")*strafeSpeed*Time.deltaTime, 0); var power = Input.GetAxis("Power"); //Truespeed controls if (trueSpeed < 10 && trueSpeed > -3){ trueSpeed += power; } if (trueSpeed > 10){ trueSpeed = 9.99; } if (trueSpeed < -3){ trueSpeed = -2.99; } if (Input.GetKey("backspace")){ trueSpeed = 0; } rigidbody.AddRelativeTorque(pitch*turnspeed*Time.deltaTime, yaw*turnspeed*Time.deltaTime, roll*turnspeed*Time.deltaTime); rigidbody.AddRelativeForce(0,0,trueSpeed*speed*Time.deltaTime); rigidbody.AddRelativeForce(strafe); }

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 gjf · Dec 09, 2015 at 08:33 PM 0
Share

please format your code properly - it's very difficult to read in your post.

when you're asking about errors, it's a really good idea to paste them - including line numbers... which is why it's important to format the code ;)

did you enter the code exactly as in the tutorial?

are you sure that it's c# and not unityscript?

avatar image NoSaintNick · Dec 09, 2015 at 09:20 PM 0
Share

Sorry I will resubmit the script in the correct order. And I am pretty sure it is C# that's what the video said as least. here is the script don't know why numbers aren't co$$anonymous$$g up they don't on my visual studio either.

using UnityEngine; using System.Collections;

public class Flying1 : $$anonymous$$onoBehaviour {

 public class CustomflightControler : $$anonymous$$onoBehaviour
 {

     public float turnspeed = 5.0f;
     public float speed = 5.0f;
     public float trueSpeed = 0.0f;
     public bool trueSpeedShiftLOC$$anonymous$$ = true;
     public float trueSpeedPosShift = 0.0f;
     public float trueSpeedNegShift = 0.0f;
     public bool LOC$$anonymous$$Set$$anonymous$$ax$$anonymous$$in = false;
     public float Set$$anonymous$$ax = 10.00f;
     public float Set$$anonymous$$in = -3.00f;
     public float strafeSpeed = 5.0f;
     public float powerShift = 0.0f;
     public float rollShift = 0.0f;
     public float yawShift = 0.0f;
     public float pitchShift = 0.0f;
     public Vector3 strafeShift = new Vector3(0, 0, 0);

     void Update()
     {
         if (LOC$$anonymous$$Set$$anonymous$$ax$$anonymous$$in) Set$$anonymous$$in = Set$$anonymous$$ax;
         if (trueSpeedShiftLOC$$anonymous$$) trueSpeedNegShift = trueSpeedPosShift;
         float roll = Input.GetAxis(“Roll”) + rollShift;
         float pitch = Input.GetAxis(“$$anonymous$$ch”) + pitchShift;
         float yaw = Input.GetAxis(“Yaw”) + yawShift;
         Vector3 strafe = new Vector3((Input.GetAxis(“Horizontal”) * strafeSpeed * Time.deltaTime), Input.GetAxis(“Vertical”) * strafeSpeed * Time.deltaTime, 0);
         float power = Input.GetAxis(“Power”) + powerShift;
         //Truespeed controls
         if (trueSpeed(-3 - trueSpeedNegShift))
         {
             trueSpeed += power;
         }
         if (trueSpeed > Set$$anonymous$$ax + trueSpeedPosShift)
         {
             trueSpeed = (Set$$anonymous$$ax - .01f) + trueSpeedPosShift;
         }
         if (trueSpeed < (Set$$anonymous$$in - trueSpeedNegShift))
         {
             trueSpeed = (Set$$anonymous$$in - .01f) – trueSpeedNegShift;
         }
         if (Input.Get$$anonymous$$ey("backspace")) { trueSpeed = 0; }
         rigidbody.AddRelativeTorque(pitch * turnspeed * Time.deltaTime, yaw * turnspeed * Time.deltaTime, roll * turnspeed * Time.deltaTime);
         rigidbody.AddRelativeForce(0, 0, trueSpeed * speed * Time.deltaTime);
         rigidbody.AddRelativeForce(strafe + strafeShift);
     }
 }
avatar image gjf NoSaintNick · Dec 09, 2015 at 10:51 PM 0
Share

try editing the original question, and capture all of the code.

and don't forget to post the error messages too - they're important ;)

0 Replies

· Add your reply
  • Sort: 

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

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

Related Questions

Help modifying code for a spaceship,How do I change the camera following settings on this script? 0 Answers

Thirdperson open doors 0 Answers

change game character/controller when inside box - RFPSP 1 Answer

How to Activate/Deactivate Component via Inputs 3 Answers

FPS Controller 0 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