GML specific coding - Laser path

This forum is for discussing shmup development, tools, engines and techniques.
User avatar
Posts: 4
Joined: Wed Mar 13, 2013 11:25 am

GML specific coding - Laser path

Postby Yano1975 » Sat Mar 16, 2013 3:50 pm

Hello i'm not sure the title is the right one but...(the title could be 'Theory about Rayforce-like lasers')

I'm making 3d vertical shmup with gamemaker (engine started a while ago).
I was making some kind of 'Rayforce/Raystorm/Raycrisis' lasers, and finally got some cool results but there is still a 'bad' path

Laser movment got a path assigned that do the curve you can see in the first screen

Image
nice curve when path moving

When the 'move_towards_point' code is assigned it goes 'directly' to the enemy breaking the curve.
Code: Select all
move_towards_point(instance_nearest(x,y,obj_BigenemyLocked).x,instance_nearest(x,y,obj_BigenemyLocked).y,2)


Image
where is my curve??

I'm not just asking for any GML code or whatever, just a theorical discussion about how it is done in the related games and such.

Thanks for interest.

User avatar
Posts: 10
Joined: Thu Aug 23, 2012 6:19 pm
Location: Finland

Re: GML specific coding - Laser path

Postby eebrozgi » Mon Mar 18, 2013 9:12 am

Hello there. Your game is looking incredibly nice. And you're making it with Game Maker, too? That is very impressive.

There are similar lasers in a GM shmup that I'm making, so here's how I did it:
The laser takes the angle between itself and the target with point_direction(x1,y1,x2,y2) and then just increases/decreases it's direction value manually to steer towards the target.

There's one more thing to note because of the way GM's direction variable works (always between 0 and 360), so I'll dump some of the game's code because I find it a bit hard to explain:
Code: Select all
var aims, looks;
aims = point_direction(x,y,target.x,target.y);
looks = direction;

//Set them up for comparison:
if looks > aims+180 {looks -= 360;}
else if looks < aims-180 {looks += 360;}

if looks < aims-12 {direction += 12;}
else if looks > aims+12 {direction -= 12;}
else {direction = aims;}

I hope this helps.

User avatar
Posts: 4
Joined: Wed Mar 13, 2013 11:25 am

Re: GML specific coding - Laser path

Postby Yano1975 » Fri Apr 05, 2013 1:56 pm

Thanks a lot for the comments.
i tried something but it missed the target when fired from some positions or start running in circle (like in orbit).
So i have to work more on it.

User avatar
Posts: 10
Joined: Thu Aug 23, 2012 6:19 pm
Location: Finland

Re: GML specific coding - Laser path

Postby eebrozgi » Mon Apr 08, 2013 12:22 am

Yeah, I ran into that problem too. My way of dealing with it was that the laser slows down if it has to steer more than about 90 degrees and accelerates again when heading straight towards the target. I noticed that a bit smaller angle than 90 worked pretty well, I believe 80 was the actual value I ended up using.

Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest