Hey guys i’m trying to get my player to rotate with the accelerometer, as well as move, and my brain has hit a brick wall. Any help would be really appreciated.
Here is my code
[lua]local playerMovement = function(event)
local player = player
local playerStats = playerStats
local accelerometerReady = accelerometerReady
local gameIsActive = gameIsActive
if accelerometerReady and gameIsActive then
local _yG = _yG
local _xG = _xG
local currentYvalue = remote.yGravity - _yG
local currentXvalue = remote.xGravity - _xG
local currentRotation = (math.deg(math.floor(currentXvalue/currentYvalue)))
player.rotation = currentRotation
local playerX = player.x
local playerY = player.y
player.x = playerX + (currentYvalue * 35)
player.y = playerY + (currentXvalue * 35)
end
end[/lua]
Ideally I would like my player to rotate slowly to match the direction. Not snap to it like it is currently doing. Also it seems like it is reaching 359 degrees and then if I need to move to 10 degrees it has to rotate anti-clockwise back. Making it very painful
Any ideas guys??
Cheers [import]uid: 26289 topic_id: 25455 reply_id: 325455[/import]