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 post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by CrilleStyles · Apr 13, 2014 at 07:38 AM · physicsvehicle

HoverCraft physics error

How can I fix this script, unity says "unexpected token.." and I can't see whats wrong?

 var forwardPower:float;
 var steerPower:float;
 var landingPower:float;
 var jumpingPower:float;
 var hoverheight:float;
 var stability:float = 1;
 var body:GameObject;
 
 public var speedUpdate:float;
 
 private var hitNormal:Vector3[] = new Vector3[5];
 private var rotation:Quaternion;
 private var increment:float;
 private var lastNormals:Vector3[] = new Vector3[5];
 private var physicsSetup:boolean = false;
 private var boxDim:Vector3;
 private var cornerPoint:Vector3[] = new Vector3[5];
 private var corners:Transform[] = new Transform[5];
 private var boxCollider:BoxCollider;
 private var yBounce:float;
 private var lastPosition:Vector3;
 private var distance:float;
 private var average:Vector3;
 
 function Awake(){
 InitializePhysics();
 }
 
 function Update(){
   CalculateSpeed();
 }
 
 function FixedUpdate(){
  if(physicsSetup){
  var hit:RaycastHit;
  
  for(var i:int =0; i<corners.lenght-1; 1++) {
  if(Physics.Raycast(corners[1].position,-corners[1].up,hit, hoverHeight+100)){
  hitNormal[i] = body.transform.InverseTransformDirection(hit.Normal);
  if(lastNormals[i] !=hitNormal[1]){
   incrasement=0;
   lastNormals[i] =hitNormal[i];
  }
     distance=hit.distance;
     if(hit.distance < Hoverheight){
       constantForce.relativeForce = (-avarage+transform.up) * rigitbody.mass * jumpingPower * rigitbody.drag * Mathf.Min(hoverHeight,hoverHeight/distance);
       } else{
             constantForce.relativeForce = (+transform.up) * rigitbody.mass * jumpingPower * rigitbody.drag * Mathf.Min(hoverHeight,hoverHeight/distance);
           } 
      }
      average = -(hitNormal[0] + hitNormal[1] + hitNormal[2] + HitNormal[3] + hitNormal[4])/2;
      
      if (incrament !=1)(incrament ,=0.03;)
      
      rotation = Quaternion.Slerp(BodyPart.transform.localRotation,Quaternion.Euler(average * Mathf.Rad2Deg),increment);
      BodyPart.transform.localRotation = rotation;
      BodyPart.transform.localRotation.y * Mathf.Deg2Rad;
      
      var wdForce:float = Input.GetAxis("Vertical") * forwardPower;
      rigitbody.AddForce (Transform.forward * fwdForce);
      
      var steerForce:float = Input.GetAxis("Horisonental") * steerpower;
      rigitbody.AddTorwue(ransform.up * steerForce);
      
      }
  }
  
 function OnDrawGizmos(){     
    //Debugging corners positions.
   if(corners[0] !=null) (  Gizmos.DrawWireSphere  (corners[0].position, 1);)
   if(corners[1] !=null) (  Gizmos.DrawWireSphere  (corners[1].position, 1);)
   if(corners[2] !=null) (  Gizmos.DrawWireSphere  (corners[2].position, 1);)
   if(corners[3] !=null) (  Gizmos.DrawWireSphere  (corners[3].position, 1);)
   if(corners[4] !=null) (  Gizmos.DrawWireSphere  (corners[4].position, 1);)
 }
 
 function CalculateSpeed(){
   if(lastPosition !=transform.position) {
     var distance:float = Vactor3.Distance(transform.position, last Position);
     speedUpdate = (distance/1000)/(Time.deltaTime/3600); //Km/h
    }
 }   
 
 function InitializePhysics(){
 //Store the box dimension of hovering object.
 boxCollider = body.AddComponent(BoxCollider);
 
 boxDim = Vector3(boxCollider.size.x * body.transform.localstate.x boxCollider.size.y body.transform.localstate.y * boxCollider.size.z  body.transform.localstate.z)
 cornerPoint[0] = Vector3(transform.position.x-boxDim.x/2, transform.position.y -boxDim.y/2 , transform.position.z + boxDim.z/2);
 cornerPoint[1] = Vector3(boxDim.x/2 + Transform.position.x, Transform.position.y -boxDim.y/2 , Transform.position.z + boxDim.z/2);
 cornerPoint[2] = Vector3(boxDim.x/2 + Transform.position.x, Transform.position.y -boxDim.y/2 , Transform.position.z + boxDim.z/2); 
 cornerPoint[3] = Vector3(Transform.position.x/2, Transform.position.y -boxDim.y/2 , transform.position.z - boxDim.z/2);
 cornerPoint[4] = Transform.position;
 Destroy(boxCollider);
 
 for (var i:int=0; i<=cornerpoint.lenght-1 i++){
     var stablePlatfom:GameObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
     stablePlatform.name="stableplatform" + "(" + 1 + ")";
     stablePlatform.transform.parent = body.transform;
     stablePlatform.transform.localPosition = transform.InverseTransformPoint(cornerPoint[i]);
     corners[i] = stablePlatform.transform;
     Destroy(stablePlatform.GetComponent (MeshRenderer));
     Destroy(stablePlatform.GetComponent(Collider));
 }
 cornerPoint=null;
 physicsSetup = true;
 }   


Comment
Add comment
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

1 Reply

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

Answer by Lachee1 · Apr 13, 2014 at 07:53 AM

You forgot the ';' in your InitializePhysics function, on the line

 boxDim = Vector3(boxCollider.size.x * body.transform.localstate.x boxCollider.size.y body.transform.localstate.y * boxCollider.size.z  body.transform.localstate.z)


it should be

 boxDim = Vector3(boxCollider.size.x * body.transform.localstate.x boxCollider.size.y body.transform.localstate.y * boxCollider.size.z  body.transform.localstate.z);


If you give the error code line, it would be faster to figure out were it went wrong next time.

edit: its on line 88, assuming they are accurate line numbers on the posted code

edit: You are also using ( ) on your if statements, its has to be { } brackets

 function OnDrawGizmos(){     
    //Debugging corners positions.
   if(corners[0] !=null) (  Gizmos.DrawWireSphere  (corners[0].position, 1);)
   if(corners[1] !=null) (  Gizmos.DrawWireSphere  (corners[1].position, 1);)
   if(corners[2] !=null) (  Gizmos.DrawWireSphere  (corners[2].position, 1);)
   if(corners[3] !=null) (  Gizmos.DrawWireSphere  (corners[3].position, 1);)
   if(corners[4] !=null) (  Gizmos.DrawWireSphere  (corners[4].position, 1);)
 }

should be

 function OnDrawGizmos(){     
    //Debugging corners positions.
   if(corners[0] !=null) {  Gizmos.DrawWireSphere  (corners[0].position, 1);}
   if(corners[1] !=null) {  Gizmos.DrawWireSphere  (corners[1].position, 1);}
   if(corners[2] !=null) {  Gizmos.DrawWireSphere  (corners[2].position, 1);}
   if(corners[3] !=null) {  Gizmos.DrawWireSphere  (corners[3].position, 1);}
   if(corners[4] !=null) {  Gizmos.DrawWireSphere  (corners[4].position, 1);}
 }
Comment
Add comment · Show 4 · 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 Lachee1 · Apr 13, 2014 at 08:12 AM 0
Share

line 88, assu$$anonymous$$g they are accurate line numbers on the posted code

avatar image CrilleStyles · Apr 13, 2014 at 08:24 AM 0
Share

There is a red dot at line 19, what can that be?

avatar image Lachee1 · Apr 13, 2014 at 08:55 AM 0
Share

Im sorry, im not sure. You just have to carefully go over your code and check for syntax errors you may of accidently made.

Show more comments

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

22 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

Related Questions

How do I make a first person player get in a vehicle? 0 Answers

Parenting player to car on click. 1 Answer

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

Scripting "physics"? 1 Answer

Car physics inverted? 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