# How do I Predict Movement?

Get help using Construct 2

### » Sun Mar 09, 2014 11:13 pm

Should work for what ever angle you want to point at.
Give or take some dt. Just so long as its a straight line.
You'll have to call R0J0hound back for curves.
B
178
S
50
G
206
Posts: 8,686
Reputation: 127,715

### » Mon Mar 10, 2014 2:39 am

newt wrote:oldX + cos(yourangle) * (30*10)= new x
oldY + sin(yourangle) * (30*10)= new y

Should work for what ever angle you want to point at.
Give or take some dt. Just so long as its a straight line.
You'll have to call R0J0hound back for curves.

It's not adding up see below:

NewX = 2000 + cos(95 degrees) * (30*10) = 1973.85327718
NewY = 528 + sin(95 degrees) * (30*10) = 826.858409428

So after traveling for 30 seconds on a heading of 95 degrees, the dot will be at 1973, 826 ?

The NewX seems to be incorrect as the dot is going South East, the X value should be increasing not decreasing.
B
34
S
10
G
5
Posts: 165
Reputation: 6,707

### » Mon Mar 10, 2014 3:11 am

The math as newt wrote works. As you wrote it is incorrect, you added some parenthesis that weren't there.

Edit:
Well, since I posted you edited your post or some nonsense like that. So now the formula is correct and the numbers look to be in the range you'd expect. If you want to be more sure of the formula then I recommend reading up on converting polar coordinates to Cartesian coordinates.
Last edited by R0J0hound on Mon Mar 10, 2014 5:22 am, edited 3 times in total.
B
100
S
38
G
134
Posts: 5,556
Reputation: 85,325

### » Mon Mar 10, 2014 3:56 am

Where?
B
34
S
10
G
5
Posts: 165
Reputation: 6,707

### » Mon Mar 10, 2014 4:19 am

Its kind of hard to know whats happening as I don't know how you've got the movement set up.
You say physics, but that would lead me to believe its not a constant speed. So the 10 * 30 may be questionable.
Or perhaps the angle you are using is off as well.
All I can say is a rate of 10 pixels per second for 30 seconds should get you a distance of 300 pixels, and and angle of 95 would point south east if the origin was the east, or that way ->.
Thats the origin C2 uses.
B
178
S
50
G
206
Posts: 8,686
Reputation: 127,715

### » Mon Mar 10, 2014 4:32 am

I have removed Physics from the equation, it is and always has been a constant speed of 10 pixels per second.

Take a look here:

I'm getting the same result, any idea what's wrong?
B
34
S
10
G
5
Posts: 165
Reputation: 6,707

### » Mon Mar 10, 2014 4:44 am

Here's a capx with the bullet behavior:
sincoswhere.capx

Also, sorry 95 is more like southwest
You do not have the required permissions to view the files attached to this post.
B
178
S
50
G
206
Posts: 8,686
Reputation: 127,715

### » Mon Mar 10, 2014 5:16 am

It's the angles that was jamming me up. 95 is southwest. Thanks. I'm still curious if this equation seems correct: Rojo mentioned I had too many parenthesis:

2000 + cos(95 degrees) * (30*10)
B
34
S
10
G
5
Posts: 165
Reputation: 6,707

### » Mon Mar 10, 2014 5:23 am

Looks fine here.
B
178
S
50
G
206
Posts: 8,686
Reputation: 127,715

Previous