• Create Account

### #Actualskuhtz

Posted 01 December 2012 - 03:33 AM

Thanks for the reply. I couldn't make out anything useful from the code you posted, but what you said before got me thinking a little differently. I revised the code to look like this:

if (fgACollisionP1.X <= player1Pos.X)
player1Pos -= Vector2.Normalize(player1Pos - fgACollisionP1) * shipSpeed;
else
player1Pos -= Vector2.Normalize(fgACollisionP1 - player1Pos) * shipSpeed;


subtracting the collision point from the players position works fine while colliding with the back end of the ship and subtracting the player's position from the collision point works the same as before. The problem though, is when I put them into this if statement the first line doesn't read. I would figure this statement would check to see if the collision takes place to the left or right of the ship?

Also, it's not actually a bouncing effect I'm getting, it's the opposite. The angles that aren't working properly actually suck the ship into the image rather than negating the movement.

### #2skuhtz

Posted 01 December 2012 - 03:32 AM

Thanks for the reply. I couldn't make out anything useful from the code you posted, but what you said before that got me thinking a little differently. I revised the code to look like this:

if (fgACollisionP1.X <= player1Pos.X)
player1Pos -= Vector2.Normalize(player1Pos - fgACollisionP1) * shipSpeed;
else
player1Pos -= Vector2.Normalize(fgACollisionP1 - player1Pos) * shipSpeed;


subtracting the collision point from the players position works fine while colliding with the back end of the ship and subtracting the player's position from the collision point works the same as before. The problem though, is when I put them into this if statement the first line doesn't read. I would figure this statement would check to see if the collision takes place to the left or right of the ship?

Also, it's not actually a bouncing effect I'm getting, it's the opposite. The angles that aren't working properly actually suck the ship into the image rather than negating the movement.

### #1skuhtz

Posted 01 December 2012 - 03:31 AM

Thanks for the reply. I couldn't make out anything useful from the code you posted, but what you said before that got me thinking a little differently. I revised the code to look like this:

			    if (fgACollisionP1.X <= player1Pos.X)
player1Pos -= Vector2.Normalize(player1Pos - fgACollisionP1) * shipSpeed;
else
player1Pos -= Vector2.Normalize(fgACollisionP1 - player1Pos) * shipSpeed;


subtracting the collision point from the players position works fine while colliding with the back end of the ship and subtracting the player's position from the collision point works the same as before. The problem though, is when I put them into this if statement the first line doesn't read. I would figure this statement would check to see if the collision takes place to the left or right of the ship?

Also, it's not actually a bouncing effect I'm getting, it's the opposite. The angles that aren't working properly actually suck the ship into the image rather than negating the movement.

PARTNERS