Page 1 of 1

Bullet direction and checkpoint system

PostPosted: Mon Jun 27, 2011 4:57 pm
by Pyathus
Hey guys so I'm trying to make it so if I am turned right, the bullet will go xvelocity++25; and if im turned left, xvelocty=-25; so I put

Code: Select all
if (bulletdir==1)
{
    xvelocity=+25;
}
else if (bulletdir==0)
{
    xvelocity=-25;
}

in my draw actor script of my bullet, and it seemed to work but if I shot a bullet right, then turned left, the bullet would turn left in mid air... and also, the bullets that I shoot left, I cant seem to position them in front of the gun since I already positioned them in front of the gun turning right. so they shoot from the same point which looks off.

and now about my checkpoint system:
my checkpoint is working, but I cant seem to get the view to continue to follow the character and be placed exactly where it was in front of the player after I get respawned at a checkpoint. and my view also stops parenting the player, or vice versa. any way that I can position my view back where it was in front of the player and continue to parent him? and if anyone has a better way to get the view to move with my character a little better without parenting, Id really appreciate it. :)

Re: Bullet direction and checkpoint system

PostPosted: Mon Jun 27, 2011 5:49 pm
by jimmynewguy
for the bullet put your script in create actor instead of draw actor

for the view try this on the player draw actor
Code: Select all
view.x = x - 160;//change 160 to half the views width
view.y = y - 120;//change 120 to half the views height

and see how that works for you

Re: Bullet direction and checkpoint system

PostPosted: Mon Jun 27, 2011 9:10 pm
by foleyjo
For the left right thing what about having an actor variable called gunposx.

When your character turns the gunposx value changes then in the create actor for the bullet put the X value as gunposx .

Or you could have the bullets zdepth below the player so no matter where the bullet comes from you don't see it until it has left the gun barrel. Though this only works if the player sprite hides the bullet till it comes out.


You could also change your bulletdir to = 1 and -1 then in the code for the bullet instead of having 2 ifs you could simply use

xvelocity = 25*bulletdir;