Page 1 of 1

having problems shooting in same direction as actor

PostPosted: Thu Sep 07, 2006 5:41 am
by ericdg
I have an actor that I want to shoot in the same direction it is facing.

I have it set up now for keydown right, changes animation to right, has x=x+2; in the script, and sets variable unit1pos=1.

The bullet has a creat actor of if unit1pos=1, then xvelocity=13;.

I have the same for left down and up.

The problem I have is going at an angle. On keydown right, up, all keys pressed, I have change animation for that direction and unit1pos=2.

I don't have to set x or y cordinates because when I press up which is y=y-2 and right which is x=x+2, it goes in the proper direction.

I have bullet with a create actor of unit1pos=2, then xvelocity=13 and yvelocity=-13.

But, now when I press right and up, my actor goes in the right direction, changes animation to the right one, but when I press spacebar, which creates bullet, it does nothing.

If I let off of right and up, the actor still faces in the correct direction, but when I press spacebar it shoots straight up.

Any thoughts?

PostPosted: Thu Sep 07, 2006 1:18 pm
by makslane
Look this example:
http://game-editor.com/examples/bullet_direction.ged

The player actor has normal key direction changes, space bar to fire the bullet and have a 'Key Down' event for 'any key' to track the last move angle of the actor:

Code: Select all
if(directional_velocity > 0.0)
{
    lastAngle = angle; //Actor variable created with the 'Variables' button
}


In the 'Create Actor' event of the bullet, just put:

Code: Select all
angle = creator.lastAngle;
directional_velocity = 5;