Page 1 of 1

Having problems when fireing bullets.

PostPosted: Mon Feb 26, 2007 10:21 pm
by FiLLLe1
Hi!
Im pretty new at The Game Creator, but im doing my best to learn. I need some help when im fireing bullets. The problem is when my player is running/standing right, the bullets go correctly - right. But when he rans/stands left, the bullets still go right. Can I fix that with scripts? Or paths? Activition events? I'm not so good at this so I need all help I can get.

What I want the player to make is:

When he stands right, he shoots right.
When he stands left, he shoots left.

EDIT" Now I also realised that I have no idea how to make an enemy try to kill to Player. Like shoot after him/chase him etc.

Would be wery thankful for answers to both of my questions.

PostPosted: Mon Feb 26, 2007 10:39 pm
by DilloDude
You need to use some variable to check which way he is facing. For example, you could just use animindex, and check the animation, or you could assign a variable when you press the keys. Then check the variable with an if statement:
Code: Select all
Actor *bullet = CreateActor("YourBullet", "bullet", "(none)", "(none)", 0, 0, false);
if (facing == RIGHT)
{
    bullet->xvelocity = 10;
}
else
{
    bullet->xvelocity = -10;
}
Or something like that.

PostPosted: Mon Feb 26, 2007 10:46 pm
by FiLLLe1
ok, i'll try that. Dont think i really uunderstand but i'll give it a try. Will reply and tell if it worked, thx for quick answer.

PostPosted: Tue Feb 27, 2007 2:09 pm
by FiLLLe1
Have I understood right now?:
The codes are Script codes i guess? And I should write the codes in the "bullet_actor" script editor? Not the "Player_actor" script editor?
(like I said before im pretty new with the programm so I dont get everything now at the beginning but i learn :)

Cuz now im doing like this:
Player_1 has an event at "Key Down" the key is space. The action is "Create actor" -> "Bullet_actor" (parent = Player_1). And that actor will directly follow the path "Bullet_path" in 60 frames or something. That makes player_1 shoot, but only in the path direction, if i create two paths at different directions, he will shoot at both directions. Should I let this setting stay or should I delete it?

You named "animindex" can i fix so the game know when the animation is standing to the right with that one, and then shoot right? If it is like that, can u say an script code to that if the actors are:

Bullet_1
Player_1

//Fille

PostPosted: Tue Feb 27, 2007 10:36 pm
by DilloDude
If you are using animindex, you can use it to check the animation that is playing. So if you have four animations: stopleft, stopright, walkleft, walkright, an animindex of 0 or 2 means you are facing left. To make the bullet move, you can either use a path, set its xvelocity, or make some other variable that effects it in draw actor. If you are using paths, then on a keydown event on your player, put this script:
Code: Select all
if (animindex == 0 || animindex == 2)//facing left, || means or
{
    CreateActor("Bullet_1", "bullet", "(none)", "PathLeft", 0, 0, false);
}
else//facing right
{
    CreateActor("Bullet_1", "bullet", "(none)", "PathRight", 0, 0, false);
}
Just check the CreateActor code to make sure I got it right. You can modify things to suit.

PostPosted: Wed Feb 28, 2007 3:27 pm
by FiLLLe1
YES! It works! thank you so much DilloDude!

PostPosted: Fri Mar 02, 2007 4:42 pm
by FiLLLe1
Hi again, i need some more help. :?
The problem now is that I've made a new animasion for my game, and now it doesent work properly. The new animation is a bazooka guy, and I want to fire bazooka rockets at the same button as the ordinary gun. i have tried to change stuff in the script you sent to me DilloDude, but i didnt make it. So if someone know how to do plz tell me.

" 1 more thing.
If a script is following:
if (animindex == 1 || animindex ==2 etc...) //like the one you posted above DilloDude. What does the numbers mean? animindex =="2".

//Fille

PostPosted: Fri Mar 02, 2007 5:33 pm
by Troodon
Animindexes go like this:

1st animation = 0
2nd animation = 1
3rd animation = 2
etc

PostPosted: Fri Mar 02, 2007 5:45 pm
by FiLLLe1
k, thx. now i think stuffs will work out :)

PostPosted: Fri Mar 02, 2007 6:25 pm
by Troodon
No problem. :)

PostPosted: Sat Mar 03, 2007 3:27 pm
by FiLLLe1
so, now i got another problem! :( srry for asking many things.
But i got a tank, when it gets blowed by a bozzoka rocket i got an animation for that, an exploding one. so now i add an collision event, when the rocket crashes with the tank, and its changeing animation like it should, but the animtion is looping. I just want it to be shown one time, then stay with the last animation, anyone know how to fix that ??

//Fille

PostPosted: Sat Mar 03, 2007 5:23 pm
by UltimatHedgehog
event animation finish
set it to change to the last pic stopped

PostPosted: Sat Mar 03, 2007 5:36 pm
by Troodon
Game Editor loops all the animations if they aren't set to be stopped. :)

PostPosted: Sat Mar 03, 2007 6:59 pm
by FiLLLe1
thx again :D

PostPosted: Sat Mar 03, 2007 7:01 pm
by Troodon
:)