Laser Bullet

Discussion and feedback on Construct 2

Post » Tue Jul 25, 2017 3:05 am

Hi,

I´m new here, I´m doing my first game using Construct 2 and I have a lot of doubts, I read some tutorial, but I don´t find how to produce laser rays from my gun?

Hope you guys help me out to solve it

Thank you
B
10
S
4
G
1
Posts: 11
Reputation: 1,272

Post » Wed Jul 26, 2017 11:20 am

Assuming you have your gun sprite and laser ray sprite ready to use:
You can create an origin point on the muzzle of your gun using the image editor [ besides the default origin point which determines the reference point of the whole image (commonly left in the middle of the image)]
after creating the additional image point, you can refer to it in the events page. lets say your gun is called sprite_gun, and you have the origin point for the image, and you also added an origin point for the muzzle of the gun. these image points will be 0 and 1 respectively. Your laser ray is called sprite_laser

After that, just create an event that creates your laser ray from your gun muzzle and imparts a force on it (or use the bullet & physics behaviours for your laser ray)
example

Code: Select all
mouse: on clicked;
- condition
action -
Code: Select all
system: create sprite_laser at position sprite_gun.ImagePointX(1),sprite_gun.ImagePointY(1) and angle sprite_gun.Angle
(the ImagePoint (1) refers to your gun muzzle, the angle ensures the laser appears at the correct angle according to where the gun is pointing)
action -
Code: Select all
sprite_laser: Impart physics force of 20
(makes the laser shoot forwards)
B
4
Posts: 8
Reputation: 277

Post » Thu Jul 27, 2017 10:32 am

Thank you

Let me try this
B
10
S
4
G
1
Posts: 11
Reputation: 1,272


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 3 guests