having problems shooting in same direction as actor

Non-platform specific questions.

having problems shooting in same direction as actor

Postby ericdg » Thu Sep 07, 2006 5:41 am

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?
ericdg
 
Posts: 53
Joined: Tue Nov 29, 2005 1:18 pm
Score: 1 Give a positive score

Postby makslane » Thu Sep 07, 2006 1:18 pm

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;
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest