Page 1 of 1

shooting

PostPosted: Tue Feb 28, 2012 12:58 pm
by BogdansB
hello

how can i make just one actor, the bullet, wich goes up when you press [8] or down if you press [2] and so on..

Re: shooting

PostPosted: Tue Feb 28, 2012 2:26 pm
by SuperSonic
Here you go :D

On key down -> [8] -> Repeat -> Script editor
Code: Select all
y -= 2;
On key down -> [2] -> Repeat -> Script editor
Code: Select all
y += 2;
On key down -> [4] -> Repeat -> Script editor
Code: Select all
x -= 2;
On key down -> [6] -> Repeat -> Script editor
Code: Select all
x -= 2;

Re: shooting

PostPosted: Tue Feb 28, 2012 2:42 pm
by BogdansB
doesn't works.

so i need to put the code in players key down event? and then bullet.x -=2? or how?

Re: shooting

PostPosted: Tue Feb 28, 2012 6:41 pm
by skydereign
If you understand the code you should be able to figure out what actor it belongs to, or to be able to apply it to the actor you need it to. All SuperSonic's code does is change the position of an actor (the event actor). So you said you wanted your bullet to move up and down on the keydown events, so give that code to the bullet.

Re: shooting

PostPosted: Tue Feb 28, 2012 6:56 pm
by BogdansB
no ment the bullet needs to create each time so its like a normal shot.
so i want every time you press [8], the bullet creates and goes up when you press [8] again, another bullet creates and so on...

Re: shooting

PostPosted: Tue Feb 28, 2012 8:54 pm
by skydereign
So both keys fire bullets, but one fires the bullet actor up and the other fires one down? In that case you can do this for your keydown events (same for the other key, just make yvelocity negative).
player -> Key Down [8] -> Script Editor
Code: Select all
CreateActor("bullet", "bullet_anim", "(none)", "(none)", 0, 0, false)->yvelocity=15; // bullet will have a yvelocity of 15

Re: shooting

PostPosted: Wed Feb 29, 2012 5:57 am
by BogdansB
thanks

Re: shooting

PostPosted: Fri Mar 23, 2012 6:02 pm
by BogdansB
how can i make it diagonal , so yvelocity and xvelocity are 15?

Re: shooting

PostPosted: Fri Mar 23, 2012 6:48 pm
by skydereign
You can use the default actor struct to do this. If you didn't already know, you can type view.x to get or change the view's x position. The same can be done here for the actor you created. Do watch out though because normally the default clone that it gets is the lowest cloneindexed one, but since you called CreateActor gE knows to update it to the newest one (but only for that event).
Code: Select all
CreateActor("actor", "anim", "(none)", "(none)", 0, 0, false);
actor.xvelocity=10; // but remember don't do this unless you have the CreateActor
actor.yvelocity=10; // otherwise it will only change the lowest cloneindexed actor

Re: shooting

PostPosted: Fri Mar 23, 2012 6:56 pm
by BogdansB
but i want to make one bullet for alldirections. i think if i do it like that , when i press up the bullet goes up and when i press down i bullet wich go up goes down ... :S you know what imean?

Re: shooting

PostPosted: Fri Mar 23, 2012 10:56 pm
by skydereign
What that code does is make the newly created bullet move with an x/y velocity of 10. So if you have a keydown event that has that script, all the newly created bullets will move in the specified direction. It doesn't however make bullets that have already been created change direction. Is that what you want?