Sine Behaviour on Grass to Simulate Wind?

  • Posted a gif below to show you an example of what I'm hoping can be accomplished.

    I know how to create the directional wind, where the angle of the sine is the same for each clump of grass. That's easy enough What I'd like to be able to do is calculate what the angle of each grass sprite should be for a radial burst of wind, based on where the burst of wind originates from relevant to the position of each grass sprite. So rather than all moving, say, 10 degrees to the right, some will move 10 degrees to the left, some 5 degrees one way, some 2 degrees, etc. Would that be possible?

  • Use: angle(x1, y1, x2, y2) to get the angle between the 2 objects.

    Then you can be even more fancy and use: distance(x1, y1, x2, y2) to calculate the distance between the objects, and depending on how far they are, you can make them wave less.

    So you will need some form of collision detections first, then you can just loop through each grass sprite that is touched and use the above calculations.

  • If you're going to bend grass, maybe you can take a look to the skew/skend effect by Somebody :

  • For like your picture you can use cos() to calculate the amount to rotate. Grass directly above and below won't rotate at all, and grass directly to the sides will rotate the most. 10 degrees in the following.

    Set angle to 10*cos(angle(centerx,centery,grass.x,grass.y))

  • For like your picture you can use cos() to calculate the amount to rotate. Grass directly above and below won't rotate at all, and grass directly to the sides will rotate the most. 10 degrees in the following.

    Set angle to 10*cos(angle(centerx,centery,grass.x,grass.y))

    Reviving and old post here, but this seems to be what I'm looking for, however I don't quite understand how to use that expression. When implementing it I get an error. What is centerx and centery?

  • "centerx" and "centery" can be replaced with any x and y you want to use as a center.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Sorry, I still don't get how to achieve the effect shown in the gif? (I'm new to Construct). I implemented the expression, but it doesn't do anything.

    I have sprite called grass, I want moving like that, what do I write, and what's the condition (I'm assuming every tick)?

  • Create an event

    every tick - grass set angle = 10*cos(angle(mouse.x,mouse.y,grass.x,grass.y))

    and move your mouse around..

  • Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)