# Rolling ball - Texture question

Get help using Construct 2

### » Fri Aug 10, 2012 5:51 pm

Sorry for deleting the last post, but I thought of something else to check, and it made my post inaccurate.

Anyways... good news is that what I came across here, makes what I was trying to accomplish a lot easier.

You can calculate angle of movement and then apply force to adjust for the object it is colliding with. Like if a cue ball hit a bumper you could apply additional force with the angle of movement.

Here is a pic of my event:

Here is how I calculated the angle:
angle(0,0,Sprite6.Physics.VelocityX,Sprite6.Physics.VelocityY)

I apply force in the direction my object is moving on collision and it gives my object an extra boost.

At least, I think this is what you are looking for.

Hope it helps.
B
16
S
1
G
3
Posts: 43
Reputation: 2,597

### » Fri Aug 10, 2012 8:59 pm

@eski, I assume when you say 'make the ball roll realistic', you are talking about just the texture? (which should be another sprite attached to the physics ball).

You should set the animation speed to:

someConstant * distance(0,0,velocityX,velocityY)

where someConstant is a number. You will have to play with it until it looks natural.

You will also need to set the angle of the image to

angle(0,0,velocityX, velocityY)

(That is assuming the rolling ball animation is rolling to the right).

Hope that helps! Be sure to ask me with @sqiddster if that doesn't work as I often lose topics like this :P
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,739

### » Mon Aug 20, 2012 11:16 am

@sqiddster
I tried your solution but it is still a problem.
This only works if the ball is rolling horizontal. Please check out the cap to see what I'm talking about.

https://dl.dropbox.com/u/4436588/pool2.capx

I don't have a clue how to fix that.
B
8
S
3
G
5
Posts: 70
Reputation: 2,834

### » Mon Aug 20, 2012 12:59 pm

https://dl.dropbox.com/u/41931267/Pool.capx

There you are.

You missed the point where I said
"You will also need to set the angle of the image to
angle(0,0,velocityX, velocityY)".

I also took the liberty of adjusting 'rolling' to around the correct amount, so the animation looks accurate.

Nice idea with the ball shine, you are going to have to do something about picking the other balls, if you want multiple shines/ball animations. I'd assign a 'baseUID' or something instance variable for each of the shines/animations, then apply their events only repspective to the ball of that UID.

Hope I helped!
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,739

### » Mon Aug 20, 2012 8:00 pm

@sqiddster

It's getting there. I actually tried the other thing as well but forgot to change it back. The only problem there is that the ball is changing angle every time it stops. It would be awesome if it was possible to make it stay at same angle.

What I'm going after is the movement like in this game.
http://www.miniclip.com/games/9-ball-quick-fire-pool/en/
Maybe it isn't possible with this engine?
B
8
S
3
G
5
Posts: 70
Reputation: 2,834

### » Mon Aug 20, 2012 9:08 pm

That looks like a 3D engine, so no, this isn't possible.

The example I gave is the best you'll get. You can stop the ball from changing angle when stopped, by adding another condition to check that both X and Y velocities aren't 0 before adjusting the angle.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,739

### » Mon Aug 20, 2012 9:19 pm

Well, it is actually good enough for what I'm looking for so it is OK. I thank you for your examples and help :P
B
8
S
3
G
5
Posts: 70
Reputation: 2,834

### » Fri Aug 22, 2014 9:31 am

Thats what i'm looking for thanks guys !
B
11
S
3
Posts: 32
Reputation: 821

### » Mon Jun 29, 2015 3:25 pm

Hi there, @eski can we get the links back if possible? thanks!
B
4
S
1
Posts: 34
Reputation: 416

Previous