Help Creating and Controlling Wind Powers!
Hi,
I'm doing a little experiment right now and testing out a concept for a game where you can control the wind by swiping up, down, left, or right. The idea is that when you swipe, this sends out a burst of wind that affects objects in its path. However, I'm having a bit of trouble.
To give an example of what I'm trying to do, imagine that you can control the wind by swiping your finger in any direction. Say that there's a tree in front of you, and a child's kite is stuck in it. The child is standing below, like this:
Tree Top
Kite
Child Tree Bottom
The player should be able to swipe to the left to knock the kite out of the tree, and then either watch it float down to the child, or assist it's downward journey by swiping downwards. Or, if they feel like being mean, swipe up or right to keep it out of the child's hands =P
In my first attempt, I tried having a unique actor for each direction - so Wind Up, Wind Down, etc. It would spawn at the player's touch point of origin (so where they started the swipe), and move across the screen in the direction that they swiped in. This worked fine, but getting it to interact with any other objects was very artificial. It's just me telling other actors to do this or that if they come into contact with, for example, Wind Actor Left. It worked okay for a simple test, but if I was making it into a real game, I feel like things would get very messy and all of the actors probably wouldn't interact correctly.
I'm now trying to work with the Gravity X and Y Scene Attributes. I have it set up so that if I swipe in any direction, the gravity will increase in that direction and so everything that's moveable will be pushed up/down/left/right. This moves the kite around just fine, but it also moves the child at the exact same speed. Now, as I say, I'm trying to think about getting this right in the context of a proper game, so just making the child be unmoveable wouldn't be a proper solution.
I guess basically what I want to know is, can I make gravity affect only specific objects? Or affect different objects by different amounts (e.g. the wind has a larger impact on the kite than the child)? Also, do you think this is the best solution for what I'm trying to do? I'd really appreciate the help, and I'd love to hear any ideas that you guys can offer.
Thanks in advance!
Comments
@CriticalGames , try to store the strength, location and direction of the swipe in global attributes. You can then use an accelerate behaviour in each actor to react independently, depending on distance and the effect it has on each object.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
Thanks for the suggestion! Very interesting idea. I hadn't even thought of using the accelerate behaviour. I'll be sure to try it out tomorrow!
Sorry for double posting, but I tried out Hopscotch's suggestion. At first, the accelerate behaviour seemed to really improve things - I did what you said and stored the strength, location, and direction and used these attributes to command the acceleration.
However, I can't get the kite to stop moving haha. I've turned the acceleration down to 0, but I presume it just keeps accelerating at whatever speed it built up. Similarly, the accelerate behaviour seems to ignore most collision events (i.e. do nothing if you're touching 'this'), so I'm not quite sure what's going on there. I'll keep fiddling, though. Thanks again!
Hi, I am a complete newby ... but doesn't the density value effect how an actor reacts to gravity? I have no idea if this would be possible or how to even go about it at the moment... but could there be some way of creating a new attribute for the actors to be effected by the wind - then have that attribute effect an actors motion and physics when x gravity = such and such?. and could it then be a timed event? so it acts like a gust of wind? or only applies to actors with a particular attribute/category?
or what you tried from hopscotch's idea... but make it a timed event? - acceleration only lasts 2 seconds or something...
will be very interested to find out what you eventually figure out because I was wondering about the exact same thing the other day when I first figured out how to apply gravity to a scene.
you can make it stop by using physics like drag.
Sorry for the delayed response (I wanted to make sure I had enough time to look into this properly), but thanks a lot for the ideas!
@scuurpro - Aha, right! I had thought there was a setting like that, but for whatever reason I was worried that it would cause problems with Move events. Thankfully, it doesn't, so that's a good way of manipulating how gravity can affect an actor. The only problem is that if you have an actor who you don't want to be affected by the gravity, you get this really jerky movement which doesn't look great.
@ScrabooliStudio - Wow, very interesting ideas! Density only seems to change how actors affect each other (the pull they have on each other, basically). Good idea about using an attribute to dictate what is and is not affected, though. Basically like adjustable tags.
I think you might be on the right track, the only problem is that gravity still affects everything, so you can't turn up that number without having some problems. However, creating an attribute like you suggested above and manipulating Linear Velocity X and Y based on that might just work.
Unfortunately, using the acceleration behaviour with a 'For' timer still doesn't stop it from moving - that Kite just keeps moving along haha. Timers can be very artificial and finicky things, so the trick will be using them to try to simulate more natural movement.
Maybe say that if 'Wind Blowing Left' attribute is on, interpolate Kite Linear Velocity X to -100 over 1 second. Based on another actor (say, once the Wind Left actor goes off screen and is about to destroy itself), 'Wind Blowing Left' will get turned off. Once it does, we go back to our Kite and say interpolate Linear Velocity X to 0 over 1 second.
Just tested it out, and it does actually work pretty well. The first main issue is that if you try and swipe in multiple directions on the same axis too quickly (while it's still at the start or middle of performing an interpolate action), you will mess up its momentum. I think this mainly has to do with the use of the interpolate behaviour, so maybe it would work better if I can find a different way of handling that.
The other problem is something I've been having difficulty with since the start - faking gravity. By this I mean making sure that when the Kite is not touching the Tree's Hit Box and is not being manipulated by wind, it's falling to the ground. Currently I'm doing this by having a long list of collision conditions and telling it to move down if they're all false, but it's pretty heavy-handed.
Still, I'd say progress has been made. Thanks again guys! =D
@Criticalgames What about setting up custom gravity for each thing using accelerate this was you can have multiple gravity's for each thing instead of one universal. It would also help with game fps.
Neat idea! But the problem with the Accelerate behaviour was that after the initial burst of acceleration, it wouldn't stop moving (even if you turned the acceleration down to 0), and it tended to ignore collision with other objects (such as the ground). I'll try and have a tinker with the concept of custom gravity unique to each actor, though.