Hi.
How can I make the ball behave realistically and by pressing/clicking on the ball keeping it in the air?
and depending on where on the ball i click it Changes its path towards a realistic angle.
I'd also like to get the ball behave like a ball in terms of rotation and so on.
Can someone help me out with this?
Thanks
Hey Tackla,
give your Sprite the Physics behavior and make sure to set the Collision mask to 'Circle'.
Then try this code:
+ Mouse: On Left button Clicked on Ball -> Ball: Apply Physics force 500 at angle angle(Mouse.X, Mouse.Y, Ball.X, Ball.Y) at image point 0 [/code:sxycirn0]
Hey Kriand!
first of all thank you for the answer.
I've got the physics behavior on the ball.
But I don't seem to understand exactly where to put in this code.
-> Ball: Apply Physics force 500 at angle angle(Mouse.X, Mouse.Y, Ball.X, Ball.Y) at image point 0
Develop games in your browser. Powerful, performant & highly capable.
I don't know.
Maybe i do it wrong.
It doesn't seem to work.
any other ideas?
You said you wanted to keep the ball in the air by clicking on it and this is the code for that: on click on ball -> apply force at angle
i'm putting the code in where it says angle.
this one, Mouse.X, Mouse.Y, Ball.X, Ball.Y
i'm pressing done and it says expression appears to be wrong.
i don't know why.
i'm using c3 is that making a differance?
it should look like this:
Alright!!!
I got it
I forgot to write (angle) in the coading!
Now it works fine!
But I've noticed that the motion is very stiff.
Do you know how to ge more Bounce in the ball?
More gravity and when i press it to Bounce back upp.
You should read the manual and try out the physics properties and variables.
scirra.com/manual/98/physics
Try using "Apply impulse" if you want to "kick" the ball.
From the tutorial:
[quote:3s8uayn2]Usually you apply a force to an object over a long period of time to cause it to accelerate in a direction. For example, gravity is a constant downwards force.
An impulse is like a sudden impact on an object. If a ball is hit with a bat in your game, you'd apply an impulse rather than a force, for a sudden one-off strike.
Thank you Dop2000
I'll try that too, cause i don't seem to be able to get it right so far.
Thank you