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 Dryden Richardson · Jun 02, 2011 at 10:45 PM · javascripterrorcollisionsbce0019

Is not a Member of Collisions

Hi, I'm new to programming and I'm using Javascript, I'm having a problem with the script though.

GRENADE_AMMO' is not a member of 'Collisions'.

 "Collisions = Collisions.GRENADE_AMMO --;"
 "Collisions.GRENADE_AMMO += 8;"

These are linked to the error i think.

Can anyone help me please?

 enter code here

var Collisions;

function OnControllerColliderHit(hit : ControllerColliderHit) { if(hit.gameObject.tag == "CrateGrenades")

{ //destroy the ammobox Destroy(hit.gameObject);

Collisions = GRENADE_AMMO --;

//add ammo to inventory Collisions.GRENADE_AMMO += 8; }

}

}

Comment
Add comment · Show 1
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 Joshua · Jun 02, 2011 at 10:50 PM 0
Share

This is not enough information to help you. Why do you think the two lines of code you poster are valid? What do you think they 'do'?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by DaveA · Jun 02, 2011 at 10:51 PM

How have you defined Collisions? Because there is no GRENADE_AMMO member variable in it. And you are setting Collisions to Collisions.GRENADE_AMMO which is strange. Can you post more code?

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 Dryden Richardson · Jun 02, 2011 at 10:55 PM

"Well, there are two peices of code, not very effietient of me but here's a piece. I'm following a tutorial btw.

//create the perfab var Crate = Instantiate(grenadePrefab, transform.position, Quaternion.identity);

//add force to the prefab grenadePrefab.rigidbody.AddForce(transform.forward * 2000);

Collisions = Collisions.GRENADE_AMMO --; print ("You Now Have "+ GRENADE_AMMO +" Grenades"); }

New Code function OnControllerColliderHit(hit : ControllerColliderHit) { if(hit.gameObject.tag == "CrateGrenades")

{ //destroy the ammobox Destroy(hit.gameObject);

Collisions = GRENADE_AMMO --;

//add ammo to inventory Collisions.GRENADE_AMMO += 8;

function OnControllerColliderHit(hit : ControllerColliderHit) { if(hit.gameObject.tag == "CrateGrenades")

{ //destroy the ammobox Destroy(hit.gameObject);

Collisions = GRENADE_AMMO --;

//add ammo to inventory Collisions.GRENADE_AMMO += 8;"

Comment
Add comment · Show 2 · 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 DaveA · Jun 02, 2011 at 11:33 PM 1
Share

First, you should get familiar with the 101/010 button above the edit area. That will format your code so it looks readable. Second, you should not answer your question, you should comment, or edit your original question. Third, there is no pre-defined Collisions class, so where is that defined (show code)? It would look like 'class Collisions' or 'var Collisions'

avatar image Dryden Richardson · Jun 03, 2011 at 10:08 AM 0
Share

Okay, I'll use Unity Answers better now when asking questions 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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Error mesige with array functions 3 Answers

Access JavaScript variables on c# script (Android build fails!) 1 Answer

BCE0049 error with networking script 0 Answers

IndexOutOfRangeExeption - Array index is out of range 2 Answers

How to make animations only play with script? 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