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 canihazaqueztion · Mar 23, 2010 at 08:34 PM · collisionplayer

Battery Collect Player Collisions Script Problems!

It throws no errors up for me but still when i start the game the battery 2d gui dissapears and when a walk into the battery nothing happens here is my player collisions script and my battery collect script.

private var doorIsOpen : boolean = false; private var doorTimer : float = 0.0; private var currentDoor : GameObject;

var batteryCollect : AudioClip; var doorOpenTime : float = 3.0; var doorOpenSound : AudioClip; var doorShutSound : AudioClip;

function Update () { if(doorIsOpen){ doorTimer += Time.deltaTime; if(doorTimer > 3){ shutDoor();
doorTimer = 0.0;
}
var hit : RaycastHit;
if(Physics.Raycast (transform.position,
transform.forward, hit, 5)) {
if(hit.collider.gameObject.tag=="outpostDoor" && doorIsOpen == false){
currentDoor = hit.collider.gameObject;
Door(doorOpenSound, true, "dooropen", currentDoor);
GameObject.Find("Battery GUI").GetComponent(GUITexture).enabled=false;
}
}
} } function OnControllerColliderHit(hit: ControllerColliderHit){
if(hit.gameObject.tag == "outpostDoor" && doorIsOpen == false){
currentDoor = hit.gameObject;
Door(doorOpenSound, true, "dooropen", currentDoor); } }

function OpenDoor(){ audio.PlayOneShot(doorOpenSound);
doorOpen = true;
var myOutpost : GameObject = GameObject.Find("outpost");
myOutpost.animation.Play("dooropen");}function shutDoor(){
audio.PlayOneShot(doorShutSound); doorIsOpen = false;
var myOutpost : GameObject = GameObject.Find("outpost");
myOutpost.animation.Play("doorshut"); }

function Door(aClip : AudioClip, openCheck : boolean, animName :String, thisDoor : GameObject){ audio.PlayOneShot(aClip); doorIsOpen = openCheck; thisDoor.transform.parent.animation.Play(animName); } function OnTriggerEnter(collisionInfo : Collider){ if(collisionInfo.gameObject.tag == "battery"){ BatteryCollect.charge++;
audio.PlayOneShot(batteryCollect);
Destroy(collisionInfo.gameObject);
}

}

@script RequireComponent(AudioSource)

and here is my battery script

static var charge : int = 0;

var charge1tex : Texture2D; var charge2tex : Texture2D; var charge3tex : Texture2D; var charge4tex : Texture2D; var charge0tex : Texture2D;

function Start(){
guiTexture.enabled = false; charge = 0; }

function Update () { if(charge == 1){ guiTexture.texture = charge1tex; guiTexture.enabled = true; } else if(charge == 2){ guiTexture.texture = charge2tex; } else if(charge == 3){ guiTexture.texture = charge3tex; } else if(charge == 4){ guiTexture.texture = charge4tex; } else{ guiTexture.texture = charge0tex; } }

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 qJake · Mar 24, 2010 at 03:01 AM 0
Share

All of your code segments need to be surrounded by

 [...] 
tags to make it easier to read.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by RPH · Nov 10, 2010 at 10:13 PM

First, make sure that you assigned the right tag to the battery objects and that they are all tagged as "battery".
I had the same problem working this example and what i found isnt so much an error on your part as a glitch in unity, so this is what solved it for me. Select one of your battery objects in the scene, in the Inspector you should have a Capsule Collider component, if you followed the example correctly. In this component is the "Is Trigger" checkbox, chances are this box is already checked, but are the words "Is Trigger" in bold?????? if not, simply decheck the box next to Is Trigger and recheck it again and "In Trigger" should now be in bold. Hopefully this helps, thats what did it for me, i think its a glitch in unity.

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

No one has followed this question yet.

Related Questions

How do I stop an immediate collision with all objects from ocuring at the entry of game mode? 0 Answers

Player Dies when Collide with enemy 2 Answers

Mesh separating from CharacterController 0 Answers

How to turn of collision for the player 1 Answer

Only targeting the targets root of vector 3 and not colliding with its mesh 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