How do I Predict Movement?

Get help using Construct 2

Post » 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.
Image ImageImage
B
168
S
50
G
163
Posts: 8,220
Reputation: 105,059

Post » 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,687

Post » 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
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Mon Mar 10, 2014 3:56 am

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

Post » 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.
Image ImageImage
B
168
S
50
G
163
Posts: 8,220
Reputation: 105,059

Post » 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:
https://www.google.com/search?q=2000+%2B+cos(95+degrees)+*+(30*10)&rlz=1C1CHFX_enUS576US576&oq=2000+%2B+cos(95+degrees)+*+(30*10)&aqs=chrome..69i57j0.4111j0j7&sourceid=chrome&espv=210&es_sm=93&ie=UTF-8

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

Post » 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.
Image ImageImage
B
168
S
50
G
163
Posts: 8,220
Reputation: 105,059

Post » 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,687

Post » Mon Mar 10, 2014 5:23 am

Looks fine here.
Image ImageImage
B
168
S
50
G
163
Posts: 8,220
Reputation: 105,059

Previous

Return to How do I....?

Who is online

Users browsing this forum: jaytrott86 and 7 guests