• Create Account

### #ActualAlanSmithee

Posted 16 April 2012 - 09:13 AM

Hello.

I am experiencing some problems with angular movement in SDL.

The Projectile is supposed to travel from static point A to static point B in a straight line.
The problem is that the angular movement seem to be snapped to whole 45 degrees.

To explain the behaviour that I am experiencing:
If there is a point A at 0,0 (x, y) that should travel to point b at 200,10 (x, y) then the object first travels 190 pixels in the x axel to 190,0 and then travels at a 45 degree angle in the posetive x, y angle.
191,1
192,2
193,3...
to
200,10

Now this isn't a very projectile like behaviour and unwanted.

My code looks like:

float radians = atan2(b.y - c.y, b.x - c.x);

c.y += 4 * std::sin(radians);

(c being the traveling object and b the goal)

What is even more wierd is that if I change the speed modifier (represented by the litteral 4 in the above code) the behaviour of the moving object differs. It seems like the faster the object is travelling the more steep angles it can move in.
At 2 speed it can only move in 45 degree angles, at 4 speed it can move in 22.5 degree angles etc.

I would be very thankful for any insight as to what might be causing this problem.

### #3AlanSmithee

Posted 16 April 2012 - 09:10 AM

Hello.

I am experiencing some problems with angular movement in SDL.

The Projectile is supposed to travel from static point A to static point B in a straight line.
The problem is that the angular movement seem to be snapped to whole 45 degrees.

To explain the behaviour that I am experiencing:
If there is a point A at 0,0 (x, y) that should travel to point b at 200,10 (x, y) then the object first travels 190 pixels in the x axel to 190,0 and then travels at a 45 degree angle in the posetive x, y angle.
191,1
192,2
193,3...
to
200,10

Now this isn't a very projectile like behaviour and unwanted.

My code looks like:

float radians = atan2(b.y - c.y, b.x - c.x);

(c being the traveling object and b the goal)

What is even more wierd is that if I change the speed modifier (represented by the litteral 4 in the above code) the behaviour of the moving object differs. It seems like the faster the object is travelling the more steep angles it can move in.
At 2 speed it can only move in 45 degree angles, at 4 speed it can move in 22.5 degree angles etc.

I would be very thankful for any insight as to what might be causing this problem.

### #2AlanSmithee

Posted 16 April 2012 - 09:09 AM

Hello.

I am experiencing some problems with angular movement in SDL.

The Projectile is supposed to travel from static point A to static point B in a straight line.
The problem is that the angular movement seem to be snapped to whole 45 degrees.

To explain the behaviour that I am experiencing:
If there is a point A at 0,0 (x, y) that should travel to point b at 200,10 (x, y) then the object first travels 190 pixels in the x axel to 190,0 and then travels at a 45 degree angle in the posetive x, y angle.
191,1
192,2
193,3...
to
200,10

Now this isn't a very projectile like behaviour and unwanted.

My code looks like:

float radians = atan2(b.y - c.y, b.x - c.x);

(c being the traveling object and b the goal)

Now what is even more wierd is that if i change the speed modifier (represented by the litteral 4 in the above code) the behaviour of the moving object differs. It seems like that fast the object is travelling the more steep angles it can move in.
At 2 speed it can only move in 45 degree angles, at 4 speed it can move in 22.5 degree angles etc.

I would be very thankful for any insight as to what might be causing this problem.

### #1AlanSmithee

Posted 16 April 2012 - 09:08 AM

Hello.

I am experiencing some problems with angular movement in SDL.

The Projectile is supposed to travel from static point A to static point B in a straight line.
The problem is that the angular movement seem to be snapped to whole 45 degrees.

To explain the behaviour that I am experiencing:
If there is a point A at 0,0 (x, y) that should travel to point b at 200,10 (x, y) then the object first travels 190 pixels in the x axel to 190,0 and then travels at a 45 degree angle in the posetive x, y angle.
191,1
192,2
193,3...
to
200,10

Now this isn't a very projectile like behaviour and unwanted.

My code looks like:

float radians = atan2(b.y - c.y, b.x - c.x);