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 /
avatar image
0
Question by gearlive · Nov 09, 2013 at 01:14 PM · errorjava

How do i fix this problem in my code? please help

Hi i'm new to coding and i just tried to code a respawn script for my game and i get two errors they are

Assets/Scripts/Respawn.js(3,4):UCE0001: ';' expected. Insert a semicolon at the end.

Assets/Scripts/Respawn.js(4,5):UCE0001: ';' expected. Insert a semicolon at the end.

Heres my script:

pragma strict

var character : boolean;

 int sealevel = 170;
 
 char spawnpoint;
 
 function Update () 
 {
 
 if(character.position.y < sealevel);
 
 (character.transform.position.spawnpoint);
 
 }
Comment
Add comment · Show 2
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 gearlive · Nov 09, 2013 at 07:31 PM 0
Share

thanks for your help i really appreciate it

avatar image cmpgk1024 gearlive · Nov 09, 2013 at 08:06 PM 0
Share

Please add replies as comments, not answers.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by $$anonymous$$ · Nov 09, 2013 at 02:44 PM

Try this...:

 var spawnPoint : Vector3;
 var character : GameObject;
 var sealevel = 170;
 
 function Update () {
 
 if(character.position.y < sealevel){
 character.position = spawnPoint;
 Debug.Log("Player has respawned");
 }
 }
 
 function OnDrawGizmos () {
 // Draw a semitransparent blue cube at the transforms position
 Gizmos.color = Color (1,0,0,.5);
 Gizmos.DrawCube (Vector3(0,sealevel,0), Vector3 (character.position.x + 100,1,character.position.z + 100));
 }
Comment
Add comment · 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
0

Answer by robertbu · Nov 09, 2013 at 02:23 PM

There are a number of errors in this code...not just syntax error but conceptual errors. You may want to take some time to work through some tutorials.

  • Line 1 - a character needs to be a GameObject or a Transform

  • Line 3 - you are mixing C# and Javascript here. This is not the way to declare an 'int' in Javascript, plus you really want this value to be a float.

  • Line 5 a spawnpoint needs to be a position in 3D space...A Vector3, and again this is not how you declare variables in Javascript.

  • Line 10 - you have a ';' at the end of your 'if', which terminates the 'if' statement.

  • Line 12 - you don't have an assignment here.

You may have wanted your code to be:

 #pragma strict
 
 var character : Transform;
 var sealevel = 170.0;
 var spawnpoint = Vector3(1.0, 2.0, 3.0);
 
 function Update () {
     if(character.position.y < sealevel)
         character.position = spawnpoint;
 }
Comment
Add comment · 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

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

19 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

Related Questions

Animation script error 1 Answer

Console Error 1 Answer

OnMouseEnter Error 1 Answer

how to put the GUI into a gameobject so that when clicked, The GUI pops up, and heres a sample multiple Choice question using GUI, i need the code for it. 1 Answer

How do you script in Java? Anyone have some exaple codes I could use? 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