# [solved] move object with speed and angle of another object

Get help using Construct 2

### » Sun Oct 16, 2016 9:18 pm

Each wooden disk in my game moves around at random angles and random speeds. The ball rolls from disk to disk.

Right now, the ball doesn't move with the speed and angle of the disks. If the device is not being tilted the ball will stay in that position, and the disk will continue moving at its current speed and angle, leaving the ball at its current position.

How can i move the ball at the speed and angle of the disk that it rolls onto, if there is no tilt registered?

Pin doesn't work, there's a fraction of lag between the tilt and the ball movement.

Last edited by jeffige on Mon Oct 17, 2016 6:00 pm, edited 2 times in total.
B
38
S
18
G
19
Posts: 664
Reputation: 14,112

### » Mon Oct 17, 2016 2:57 am

Still trying to figure this one out. No examples or tutorials. Old posts have dead links.

Open for suggestions.
B
38
S
18
G
19
Posts: 664
Reputation: 14,112

### » Mon Oct 17, 2016 5:04 am

You can rotate a point around another using a formula like the one here:
https://www.siggraph.org/education/mate ... 2drota.htm

And here's a cursory example of that applied:
https://dl.dropboxusercontent.com/u/542 ... otate.capx

You could probably do it with less math, but I'm not feeling especially creative.
B
97
S
36
G
131
Posts: 5,519
Reputation: 83,476

### » Mon Oct 17, 2016 2:14 pm

Thank you for the reply @R0J0hound but that's not what i need.

Example: if you are pulling a little red wagon and a squirrel runs and jumps onto that little red wagon and stops, the squirrel's angle and speed will change to that of the little rd wagon.

My wooden disks move at random angles and speeds. The player must tilt the device to roll the ball around while staying on top of these disks. If he falls off the edges of the disks, it's game over.

Right now, if the player is on top of a disk and stops tilting the device the ball stops moving, it stays in that exact X and Y location while the disk keeps moving on its current path, and does not move again until the player tilts the device to move the ball again.

capx example https://www.dropbox.com/s/6t3i4sr6obi0sde/Ball%20on%20Sq_001.capx?dl=0

I need it so if the ball is on top of a disk and the player stops titling the device, the ball will continue to move with the disk. I'm sure it has to do with something like:

Ball - overlapping disk
Touch -gamma is 0 > ball - set speed to disk.bullet.speed

Ball - overlapping disk
Touch -gamma is 0 > ball - set angle to disk.bullet.angle

Or something like that. I just can't find any posts, examples or tutorials and i can't figure this out.
B
38
S
18
G
19
Posts: 664
Reputation: 14,112

### » Mon Oct 17, 2016 3:17 pm

Just added a capx example with tilt and keyboard support, to get a better understanding of what i mean.
B
38
S
18
G
19
Posts: 664
Reputation: 14,112

### » Mon Oct 17, 2016 4:12 pm

With a capx, i understand the question.

https://www.dropbox.com/s/tuacfqmdl89ao ... .capx?dl=0
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Mon Oct 17, 2016 5:28 pm

@99Instances2Go

I was so worried i wouldn't be able to figure this out, making me rethink and edit almost my whole game. Exactly what i needed.

I LOVE YOU
B
38
S
18
G
19
Posts: 664
Reputation: 14,112