Topic: Mouse and cursor key movement

Hi,

Im working on a new project here, and while Ive used the Tutorials and Sponza as examples, I'm unable to get the camera to work up and down ( only tracks horizontally), and when I press UP on keyboard it goes left instead, and LEFT goes forward,,,,any idea what I've got set wrong atm ?

When I move the mouse to rotate view in game, it rotates left/right as it should, but when I try moving mouse UP/down, the view TILTS left/right.

thx
Gm

Re: Mouse and cursor key movement

Hi,
is it also doing that on Sponza example ?
the best is if you can show us your script

Re: Mouse and cursor key movement

It does not have this odd behavior in Sponza,which is odd because Im following the exact same behavior , given im using the script from sponza and simply loaded the box mesh and duplicated it as shown in one of the tuts for maratis online.

I then created the values as given in sponza and it works fine except for these few things..Ive double checked and I simply can't find what I've got incorrect here, but yes I'd be happy to post script Im using .

My script which is exact duplicate of sponza script:

-----------------------------------------------------------------------------------
-- Maratis
-- Jules script test
-----------------------------------------------------------------------------------

-- get objects
Player = getObject("Player")
Head = getObject("Head")

dx = 0.0
dy = 0.0

centerCursor()
mx = getAxis("MOUSE_X")
my = getAxis("MOUSE_Y")

-- scene update
function onSceneUpdate()

    -- rotate Player (X mouse)
    rotate(Player, {0, 0, -1}, dx*100)
   
    -- rotate Head (Y mouse)
    rotate(Head, {-1, 0, 0}, dy*100, "local")   
    rotation = getRotation(Head)
    if rotation[1] > 90 then
        rotation[1] = 90
    elseif rotation[1] < -90 then
        rotation[1] = -90
    end

    setRotation(Head, rotation)
   
    -- move
    if isKeyPressed("UP") then
        addCentralForce(Player, {0, 3, 0}, "local")
    end
   
    if isKeyPressed("DOWN") then
        addCentralForce(Player, {0, -3, 0}, "local")
    end
   
    if isKeyPressed("LEFT") then
        addCentralForce(Player, {-3, 0, 0}, "local")
    end

    if isKeyPressed("RIGHT") then
        addCentralForce(Player, {3, 0, 0}, "local")
    end   
   
    -- get mouse direction
    dx = getAxis("MOUSE_X") - mx
    dy = getAxis("MOUSE_Y") - my

    -- center cursor
    centerCursor()
   
    mx = getAxis("MOUSE_X")
    my = getAxis("MOUSE_Y")   
   
end


My box.mesh ( brought in direct from sponza DIR) has properties in editor, which match their sponza values, as does head and camera, so I'm lost as to what I'm doing wrong here . My parenting is also precisely matching sponza example as are all other value, afaict.

I realize I could just use sponza mproj and del building and load my mesh instead, but I'd rather know why what I'm doing isn't having intended effect so I can learn Maratis effectively.

thx
Gm

Re: Mouse and cursor key movement

Hi,
yes indeed the script is the same,
so the problem is probably from the level itself,
check that the rotations coordinates are the same than in sponza :

- Player : 0 0 -90
- Head : 0 0 0

Head parent is Player
Camera parent is Head

Also check that the scale of Player and Head are uniform (meaning the same scale for x, y and z)
a non-uniform scale on a 3d object can deform it's children's coordinates.

Re: Mouse and cursor key movement

Ok thanks that has it, as it turned out that all parenting was totally correct ( given I 'd followed tut precisely), but somehow I had missed that the camera must be centered in head or it throws off the balance act wink > Being new to this, it's a tad tricky following all the necessary positioning , but it does make sense after seeing it in action that the scripting values would indeed throw things way off if initial values aren't correct.

I think expecting someone to know such values is a bit outside the knowledge base of most people. I can put this in as a 'feature request',but before I do, I shall mention it here:

I think to avoid having to load a given mproj ( sponza in this case), it would be far easier (i'd code it myself if I could) to have PRESET's that would make life much easier. Having to enter rotation values for objects is a mind numbing thing ( glad I know about it though) when we are talking about something so basic as movement in a game, and that when those values are wrong, it causes a great deal of mayhem.

I honestly don't even recall the TUT I watched for maratis, saying anything about needing to 'set' those values to things to work correctly.

thx wink)
Gm