How do I make the sine work on this laser?

Just started using Construct 2? Post your questions here

Post » Sat May 30, 2015 5:57 pm

So I've got this laser that can be blocked by a box. The only problem is that the size is set to Every Tick, and therefore the sine will not respond.

What's another way to get the sine to work and to have the same outcome? With the box being able to block the laser.

Simply drag the black box in front of the laser, and the laser will be blocked.

https://www.dropbox.com/s/rdq647m62is22 ... .capx?dl=0
Risk Rocket now available on Google Play
Image
B
36
S
15
G
6
Posts: 337
Reputation: 6,300

Post » Sat May 30, 2015 6:27 pm

The idea, right, is that you extend your laser until it hits something ?

Your event 3 works, but the problem is it doesn't stop in the repeat to update everything.

What you can do is

At the top of 1, Laser set Width to 10 (this sets the initial size of the laser)
Change 2 to Laser set Height to 2 (if you set the width here it will change it back every time - it goes through the events many times a second - this is the reason the sine doesn't appear to work, you keep setting it back to 2)

Change the first condition in 3 to "System Every 0.3 seconds" - this means the laser will extend every 0.3 seconds
Change the Set Width to Laser.Width to 5 - so every 0.3 seconds the laser will be 5 pixels wider until it hits the object.

This is very slow but it will allow you to see what is going on.

Construct 2 is event and timer driven. It is a different way of thinking to procedural programming.
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Sun May 31, 2015 7:17 pm

Is this what you meant? https://www.dropbox.com/s/drxzs25u13fem ... .capx?dl=0

This could also fit into my game quite well, but the Sine still doesn't work and doesn't solve my initial problem.

The laser doesn't need to grow, it's already a straight laser, just as the first one. Kinda like a laser fence, it just stays there and by putting a box in front of the laser, it just blocks the path of the laser.

As I said though, your idea is quite cool as well!
Risk Rocket now available on Google Play
Image
B
36
S
15
G
6
Posts: 337
Reputation: 6,300

Post » Sun May 31, 2015 9:42 pm

Not quite sure what you are trying to do here - you want the laser height to pulse up and down following the sine wave, right ? You can do that by just setting width rather than size. Your actions are having a punch up between each other about who actually controls the height and width at the moment.
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Sun May 31, 2015 9:52 pm

I am not a smart man. Thanks, Paul.

https://www.dropbox.com/s/hmmrgrpvhmtz8 ... .capx?dl=0
Risk Rocket now available on Google Play
Image
B
36
S
15
G
6
Posts: 337
Reputation: 6,300

Post » Mon Jun 01, 2015 10:45 pm

@Usman Haq
You don't have to. You just need to understand:
https://dl.dropboxusercontent.com/u/659 ... aving.capx
ImageImage
B
105
S
46
G
23
Posts: 778
Reputation: 22,226


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest