# Reverse the sine behavior?

Get help using Construct 2

### » Sat Aug 25, 2012 11:05 am

I wanted to implement an effect where my swaying grass would be pushed by the player moving past it. My test works perfectly when they're moving in the same direction, but if the grass is swaying left while you pass it going right, well, I want to make it reverse direction and start swaying right.

I can't seem to find a way to do that, unless I'm overlooking something right under my nose. Anyone know something I don't?
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

### » Sat Aug 25, 2012 11:16 am

I'm not sure if this is possible, but maybe you can set the magnitude of sine to a negative number, or have a second sine behavior set to a negative number and switch between them when the player comes in overlaps with the grass?Zero62012-08-25 11:16:47
B
13
S
4
Posts: 117
Reputation: 2,242

### » Sat Aug 25, 2012 11:28 am

That looked like it was going to work at first, but turns out it doesn't... Unless it switches sine behaviors when it's in the starting position (completely upright, no sway), the new behavior picks whatever position it IS at to be it's OWN starting position... which makes it get all out of whack if you have any idea what I'm saying.

The easiest solution would be for a "Reverse Sine" button... *coughcough @Ashley coughcough*
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

### » Sat Aug 25, 2012 11:46 am

haha that's nasty but I'll post it anyway

Have no idea what and when it was made but, well..

looled grass
B
140
S
58
G
37
Posts: 2,549
Reputation: 31,711

### » Sat Aug 25, 2012 9:10 pm

Haha well that's a interesting... style of grass. I might have to do something similar with manually controlling the angles though if reversing it isn't an option.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

### » Sat Aug 25, 2012 9:46 pm

I'd just create my own sine behavior. Or, at least use 'value only' and apply it to the angle using your own method which allows this.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,455

### » Sat Aug 25, 2012 10:06 pm

That's what I've been figuring, but... will there be a performance difference? I mean, I use a LOT of grass. A stupid amount, really. The level I'm working on isn't even half done and there's 208 grass sprites. I'll eventually put in options to turn off certain effects, probably replacing the individual sprites with static tiled backgrounds, so I guess it's not a huge deal.

But in the same way the particle system is more efficient than you spawning the sprites yourself, is the sine behavior more efficient than manually rotating all the grass (maybe 30-40 on screen at once)?
B
20
S
9
G
6
Posts: 607
Reputation: 6,112