character not facing the right location [SOLVED]

Started by Theme, Sun 31/07/2005 15:22:31

Previous topic - Next topic

Theme

I use
player.FaceLocation(x,y);
and at some random places the character doesn't face the right location

o/

DoorKnobHandle

Could you give some more code? When does this occur?

Are you sure you don't mix up x and y?

strazer

Keep in mind that FaceLocation expects screen coordinates, so if you have a scrolling room, you have to substract GetViewportX and GetViewportY from room coordinates (object coordinates, character coordinates, hotspot walk-to points etc.):

  player.FaceLocation(oDoor.X - GetViewportX(), oDoor.Y - GetViewportY());

Theme

i have a scrolling room
i tryed:

guicoinmouseclickx = mouse.x;
guicoinmouseclicky = mouse.y;
and then
player.FaceLocation(guicoinmouseclickx-GetViewportX(),guicoinmouseclicky-GetViewportY());

but it didnt work

o/

strazer

Mouse coordinates already are screen coordinates, so you don't have to substract the viewport position for them. Ignore my suggestion then.

To quote [...]:
QuoteCould you give some more code? When does this occur?

Theme

it worked now:

player.FaceLocation(GetViewportX()+mouse.x,GetViewportY()+mouse.y);

mouse gets screen coordinates and facelocation uses room coordinates
thanks for the help

o/

strazer

Quotefacelocation uses room coordinates

Not according to the manual, but you're right, it does. Good work!

SMF spam blocked by CleanTalk