# Sine behavior

Get help using Construct 2

### » Wed Nov 06, 2013 2:48 am

mindFAQ you're the best. i have no idea what the math does; but it works and exactly as i wanted it. i have one last question: if i add the code to a sprite and give the sprite the bullet-behavior then the sprite moves left to right. i want to have it move vertically. how can i do that? that's the last part of the puzzle. can you please help? thanks again for all your help.
B
151
S
48
G
11
Posts: 136
Reputation: 15,255

### » Sat Nov 09, 2013 1:53 am

MindFAQ! Thank you for your help, and I have tried your formula, but something is not working and I am not sure where I went wrong.

Basically the enemies started oscillating in a uniform vertical direction really fast.

(Strafer is my enemy sprite that I want the weaving to be implemented)

It seemed to work fine when I got rid of the A (period) and B (amplitude) modifiers and getting rid of lastX and lastY. Except when I try to modify its A and B, that's where it goes haywire.

I will post a video if you need/ don't quite understand what I am talking about.

Thanks : )DRTIAN2013-11-09 01:54:40
B
9
S
3
Posts: 7
Reputation: 1,064

### » Sat Nov 09, 2013 2:19 am

[QUOTE=hyem] mindFAQ you're the best. i have no idea what the math does; but it works and exactly as i wanted it. i have one last question: if i add the code to a sprite and give the sprite the bullet-behavior then the sprite moves left to right. i want to have it move vertically. how can i do that? that's the last part of the puzzle. can you please help? thanks again for all your help.[/QUOTE]

I didn't see this. If you want it to fly into another direction with the bullet behaviour, just modify the angle or the angle of motion of your sprite. An angle of 90 will make it move downwards, 270 upwards. If you change the angle, your picture will be rotated, if you only change the angle of motion, the picture will not rotate.

@DRTIAN: the on created event only triggers once when the object is created. We need to modify lastx and lasty each tick after the set position ran (just place them after it). Also I had a typo in my formula, instead of the 50 at set y (not sure where the 50 came from), it needs to be B if I overview this correctly. Hope it works now.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

### » Thu Nov 14, 2013 1:53 am

awesome, thanks a million mindfaQ, you're the best !!! thanks for all your help, it works like a charm now
B
151
S
48
G
11
Posts: 136
Reputation: 15,255

Previous