Hi community!
I'm working on a wing commander type of game, that the player is supposed to control with the mouse. The background is much larger than the cockpit on screen, so the scene should always scroll towards the mousecursor. Since there is no "center on mousecursor"-action, i thought, i would write a small script for the main (invisible) character to always follow the cursor and then have the screen always centered on him. Here's the script:
local curPos = getCursorPos()
local char, pos
function setCharPos()
char = game:getLink(VGameCurrentCharacter)
pos = char:getPoint(VCharacterPosition)
game.CurrentCharacter.Destination = {x = curPos.x, y = curPos.y}
end
setCharPos()
This works fine, until the cursor reaches the edge of the screen and the scrolling sets in, because when the screen starts to move the character is "left behind" and can't "catch up" to the cursor anymore
Basically, the character doesn't follow the cursor anymore while scrolling.
Any ideas on how to improve the script or how to center the scrolling on the mousecursor itself?