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 cptnight · Nov 08, 2010 at 12:25 AM · errorsyntax-errorbce0044

Basic on collision play animation code not working

I am trying to play animation on collision, my script should be almost identical to that of will goldstones - the sounds and the door closing yet, i continue to get errors about = ; : when i replace with those it still says expecting.

var doorOpened : boolean = false;

function OnControllerColliderHit(hit:ControllerColliderHit){ if((hit.gameObject.tag == "drilldooropen") && (doorOpened == false)){ openDoor(); } }

function update () function openDoor(); { doorOpened = true;
var drill = gameObject.FindWithTag("drilldooropen"); drill.animation.Play("Take 001"); }

very new to unity but exp with 3ds animations the animations are fine.

Assets/Standard Assets/Camera Scripts/Opendoor.js(15,2): BCE0043: Unexpected token: function. Assets/Standard Assets/Camera Scripts/Opendoor.js(17,30): BCE0044: expecting :, found '='.}}

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 zannghast · Nov 08, 2010 at 01:34 AM 0
Share

can you post the Opendoor.js script?

avatar image cptnight · Nov 08, 2010 at 01:37 AM 0
Share

sorry, there we are late night really tired maybe thats part of the problem

1 Reply

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

Answer by skovacs1 · Nov 08, 2010 at 03:20 PM

There are two main problems with your script:

  1. You declare a function update with nothing after it, no implementation, no semi-colon, nothing.
  2. You declare a function openDoor, followed by a semi-colon. Then you open a block with a brace. If you were trying to implement the function you just declared, you should not have ended the declaration with that semi-colon.

Here's probably what you wanted:

var doorOpened : boolean = false;

function OnControllerColliderHit(hit:ControllerColliderHit) { if((hit.gameObject.tag == "drilldooropen") && !doorOpened) openDoor(); }

function openDoor() { doorOpened = true;
var drill : GameObject = gameObject.FindWithTag("drilldooropen"); drill.animation.Play("Take 001"); }

Also, a small improvement, rather than having to find the GameObject every time, you could just pass it in:

var doorOpened : boolean = false;

function OnControllerColliderHit(hit:ControllerColliderHit) { if((hit.gameObject.tag == "drilldooropen") && !doorOpened) openDoor(hit.gameObject); }

function openDoor(drill : GameObject) { doorOpened = true;
drill.animation.Play("Take 001"); }

If you're going to have more than one door, your mechanism doesn't seem very scalable. Perhaps you should consider storing whether the door is open on the door rather than the door opener.

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 cptnight · Nov 09, 2010 at 12:17 AM 0
Share

thank you for the time you took to look at my mistakes i see where i went wrong and it works perfectly now i have changed it as you said to the door and it works :) thanks

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

No one has followed this question yet.

Related Questions

I need help with an error 1 Answer

error help 2 Answers

script not working 2 Answers

Script error. Please Help! 4 Answers

BCE0044: expecting ':' found ';' 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