# Thread: Pushing/Anti-Gravity Wind Effect in AS2

1. 1
posts
Registered User

## Pushing/Anti-Gravity Wind Effect in AS2

Alright guys, so I'm making a game. I want there to be a part where an air vent is pushing against the ball your controlling with your mouse. If you don't get it, check out the swf file from megaswf.com. Trust me, it's safe. No download needed. http://megaswf.com/serve/1008636

As you can see, I've got the idea. That's what I want, the wind pushing the ball and you have to force yourself to push it forward with your arrow/mouse.

The only thing is there's no variation.

I want as you get closer to the right side, the wind gets stronger, and the farther you get from the right side, the calmer the wind gets. Here's some basic snipets of the code I used for the wind to react with the ball. This is not the entire code used in the swf.

Code:
```//Here's the strength of the gravity.
gravity = 0.40;

ball.onEnterFrame = function() {
//there was some more code here that didn't really have anything to do with the wind.
xspeed -= gravity;

}```
I would really appreciate it if you helped! Thanks!

2. 16
posts
Registered User
First off, to give the wind some variation, either try producing a random number for it's strength, or a random delta strength (A small random value you add to the current strength, so the change in strength isn't so sudden).

Another idea is to have it set on a tween (get the sine of the current frame * Math.PI / 180, which would I guess sort of be a fan pushing wind in gusts (not realistically, but hey, it's a game).

I guess just have fun with the gravity variable in real time!

As for the distance thing, just do what you did for the ball pushing, and have the wind strength be something like 1 / distance^2 * gravity (gravity in this case should be huge). That's basically the gravity equation too, except in this case it's pushing the ball away from it's origin.

P.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•