Page 1 of 1

Destroy actor Glitch.. i think.

PostPosted: Thu Jul 19, 2007 4:23 pm
by Caaz Games
i think theres a glitch or some thing in ge, every time i try to add a create actor in the destroy actor event, it wont work, when the actor is destroyed, nothing happens, theres no error messege or anything, heres the code i'm useing.
Code: Select all
int n;
n=rand(1);
if (n==0)CreateActor("HealthDrop", "HealthDrop", "StarTrak", "(none)", 0, 0, false);
if (n==1)CreateActor("UpgrdDrop", "UpgrdDrop", "StarTrak", "(none)", 0, 0, false);
ive even tried :
Code: Select all
CreateActor("HealthDrop", "HealthDrop", "StarTrak", "(none)", 0, 0, false);
but it still wont work :(

PostPosted: Thu Jul 19, 2007 5:32 pm
by d-soldier
Dunno what the problem would be... I have actors created from my destroyactor scripts in nearly every actor without ever having a problem... I'd check the actors that are supposed to be created by putting them where the player starts and setting them to be created on startup, thereby watching to see if they react as you want them to from the get-go... The process of elimination would suggest that if they work fine while created at startup, the problem must be in the destroy-actor script somehow...

PostPosted: Thu Jul 19, 2007 7:24 pm
by makslane
Use:

Code: Select all
n = round(rand(1));

PostPosted: Thu Jul 19, 2007 8:06 pm
by summer_goth
I might be wrong in this but don't rand return a number between zero and the maximum number? In that case the maximum value is not one of the values that will be returned. I think that makslane's code will work or try this:

Code: Select all
int n=rand(2);
if (n==0)CreateActor("HealthDrop", "HealthDrop", "StarTrak", "(none)", 0, 0, false);
else if (n==1)CreateActor("UpgrdDrop", "UpgrdDrop", "StarTrak", "(none)", 0, 0, false);


That should work if memory serves correctly. If not then I apologise. :wink:

PostPosted: Thu Jul 19, 2007 10:05 pm
by pixelpoop
rand() always includes 0 as one of the possibilities, so...

rand(1); can only equal zero.

rand(2); can equal zero or one.

PostPosted: Fri Jul 20, 2007 7:10 am
by Caaz Games
:) yay now it works.