Jump to content

au3irrlicht - moving a scene node


aNewLyfe
 Share

Recommended Posts

Hi, after 2 days i've gave up.

Problem is: i want to move a node forward by a keypress for example W. Well, moving on x+, x- or z+, z- is done. But i want to move node to forward. (Where it looking, facing at)

variables i got: node rotation, node speed, node x,y,z points.

Tried something like:

$NODE_X += (cos(($PI/360)*($NODE_YROTATION+90))*$MOVE_SPEED)

$NODE_Z += (cos(($PI/360)*($NODE_YROTATION+90))*$MOVE_SPEED)

bad idea? :x my math is FF btw.

Really waiting 4 your help.

:alien: ~ Every Living Thing is a Code Snippet of World Application ~ :alien:

Link to comment
Share on other sites

you can create additional nodes (front, back left and right) that are too small to see. make them child nodes of the main node and when you movement key _ispressed() then set the main node position to the position of the front (back left or right) node

$dll = DllOpen("user32.dll")
If _IsPressed("57", $dll) Then;w
            $posf = _IrrGetNodeAbsolutePosition($FrontNode)
            _IrrSetNodePosition($node, $posf[0], $Pos[1], $posf[2])
        ElseIf _IsPressed("53", $dll) Then;s
            $posb = _IrrGetNodeAbsolutePosition($BackNode)
            _IrrSetNodePosition($node, $posb[0], $Pos[1], $posb[2])
        EndIf
Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

you can create additional nodes (front, back left and right) that are too small to see. make them child nodes of the main node and when you movement key _ispressed() then set the main node position to the position of the front (back left or right) node

$dll = DllOpen("user32.dll")
If _IsPressed("57", $dll) Then;w
            $posf = _IrrGetNodeAbsolutePosition($FrontNode)
            _IrrSetNodePosition($node, $posf[0], $Pos[1], $posf[2])
        ElseIf _IsPressed("53", $dll) Then;s
            $posb = _IrrGetNodeAbsolutePosition($BackNode)
            _IrrSetNodePosition($node, $posb[0], $Pos[1], $posb[2])
        EndIf

well tnx 4 reply and your time.

But i've found the formula after 3 days :x

((Cos(direction degree * pi number / 180) * node movement speed))

:alien: ~ Every Living Thing is a Code Snippet of World Application ~ :alien:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...