Page 1 of 1
NEED HELP WITH VARIABLES PLEASE
Posted:
Mon Jul 31, 2006 7:33 pm
by PJ
on my last post, somebody told me to use variables to make my player shoot both ways. right now, when hes facing right, the bullet comes out of his back. can someone PLEASE write the variable for me? thanks.
Posted:
Mon Jul 31, 2006 9:34 pm
by relaxis
post me your code so far.
this is one way to do it.
Posted:
Tue Aug 01, 2006 8:05 pm
by hollywoodcolor
//no left or right key have been pressed yet
if (lastDirection == 0)
DestroyActor("bullet");
// left key is last pressed
if (lastDirection == 1)
xvelocity =-20;
// right key is last pressed
if (lastDirection == 2)
xvelocity =20;
//this script is for your bullet actor under create actor
//in the script window click on Variables
// in the "User Variables" click on add
//under Name: put lastDirection and leave the defaults and click the add //button
Posted:
Wed Aug 02, 2006 1:05 pm
by relaxis
can you have continous conditionals like that? just use "if" with no "else" iver and over?
it's kinda inefficient...
Posted:
Wed Aug 02, 2006 6:38 pm
by hollywoodcolor
Yes you can have "can you have continuous conditionals"
The code was pulled from working a script.
You are most likely correct in that one (if statement with else parts) would be more efficient
Do you know if there is a good way to test the difference in speed on something like this?
Posted:
Thu Aug 03, 2006 12:32 pm
by relaxis
well I guess that for one statement it would matter too much as long as if it were a one-time event (not in the controls - just a scene in the game).
But I suppose that a fps counter of somekind or a benchmarking tool could work. ask around.
Personally I would have devised some kind of "while loop" or used case switches. But even case switches are inefficient.