Actor Bouncing across screen
So I've got this endless runner. My hero flying around trying collect points from things that are spawned just off screen on the right side and scroll across to the left. I've also got a couple of other things like foreground and background objects also doing the same thing. This all works - which is great. I now had the idea (of course, just to make it more difficult) of having an actor be spawned from the right just like all of the rest - except arc to the 'ground' and bounce off screen (left). - just like a ball would do. I looked around and found this discussion: http://forums.gamesalad.com/discussion/74615/keep-object-from-moving-on-y-axis-random-y-position
Someone came up with a solution which worked for the poster, but not for me. Here's what he said to do:
@Rabid Parrot said:
Create a real attribute within the building actor. Call it "MyY".Add the following statement to the building actor.
Change attribute self.MyY to self.posY
Make another rule,
If self.posY < self.MyY
constrain attribute self.posY to self.MyY
What I've also done is enter a value (3) into the Y coordinate of Gravity in the scene attribute and applied the above. My actors still slide off screen - downward.
Comments
Example attached . . .
Thanks @Socks That looks like it should work within my game – and surprisingly simple. I noticed that you didn't enter any values for gravity in the scene attribute. I thought that if something were to behave as if there was gravity you had to enter a value in there.
If I were you I would avoid scene gravity, most people just apply a downwards acceleration to the object they want to be effected by gravity, this gives you much more control.
@Socks I'll take your advice - it made a mess of my game. I'm puzzled though. Your ball actor shoots out at 270 (which as I understand it, is left), the ball then slowly falls to the ground and bounces. I can understand that the bounce comes from the physics of the actor. But why is it falling?
270 is down. There are only three things happening in @Socks' demo:
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Like Armelline says 270° is down, in maths 0° is at the 3 o'clock position and angles increase as you move counterclockwise.
@Socks @Armelline ..ohhhhh.. I get it. Sorry, I'm not very cluey at all – especially with maths. I think I really should have known what 270 meant though. In school (which was a-hem, some time ago now), I was the kid scribbling all over his folder during maths. Regrets. I've got it working – just started tweaking the amount of bounce etc. Thanks again, again – both of you.
Socks has a way of making things so simple they're confusing (which is a good thing!). I'll admit I opened his project and spent a good minute going "How the fudge is he making the balls move left?" before it occurred to me he might have set a default linear.velocity.x value.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support