Anyone know about scripting in unity?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  01 January 2011
Anyone know about scripting in unity?

I know this is not really the proper place but seeing as there is no general scripting on unity forum, I figure the fine gents over here may be able to help me out. Tried the unity forum but I'm not getting much help. Anyway here is whats going on;

I'm trying to make a small script to switch weapons (they're actually bottles of cleaning agent... dont ask) in my FPS. I'm using the SetActiveRecursive command to make the different "weapons" appear. The code I'm using is simple so I thought it wouldn't really give me any problems, but that assumption was dead wrong. Currently The first weapon works great, (shuts on and off when I switch keys) the rest dont work at all and the last weapon is constantly in an on state and wont shut off even though I have the active box unchecked, as soon as the game starts it checks it's self on. Here is the code so far, if anyone could help I would be very appreciative!

var HFS : GameObject;
var HMS : GameObject;
var HAP : GameObject;
var HPO : GameObject;

function Update () {

if (Input.GetKey(KeyCode.Alpha1))

HFS.SetActiveRecursively(true);
HMS.SetActiveRecursively(false);
HAP.SetActiveRecursively(false);
HPO.SetActiveRecursively(false);

if (Input.GetKey(KeyCode.Alpha2))

HFS.SetActiveRecursively(false);
HMS.SetActiveRecursively(true);
HAP.SetActiveRecursively(false);
HPO.SetActiveRecursively(false);

if (Input.GetKey(KeyCode.Alpha3))

HFS.SetActiveRecursively(false);
HMS.SetActiveRecursively(false);
HAP.SetActiveRecursively(true);
HPO.SetActiveRecursively(false);

if (Input.GetKey(KeyCode.Alpha4))

HFS.SetActiveRecursively(false);
HMS.SetActiveRecursively(false);
HAP.SetActiveRecursively(false);
HPO.SetActiveRecursively(true);
}
 
  01 January 2011
never mind solved my issue, wasnt using a closed bracket between operations
 
  01 January 2011
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 06:43 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.