Help Support the Baja Engine! Donate to Breezeway Studios!

Baja Engine -> Forum -> Engine -> Scripting -> object contol via mouse    |   [Search Forum]

object contol via mouse

New Post New Topic New Poll
jkaoz Posted: October 21, 2007, 12:39 PM quote

Newbie
*
Group: Testers
Member Id: 392
Joined: Oct 17 2007
Posts: 0
Hey,
what I'm trying to do is control an objects rotation using the mouse.

but when i get into the game, theirs no movement, Did I screw up any place in particular?

Code

--this is the main script--

function main()        --called when the engine starts
        mouse.visible=false        --hide the mouse
        camera.fly=false        --don't worry about collisions yet
        camera.freeze=true  --disables defualt cam control
        level.load('cam_tester/cam_tester.lml')        --load our level
       --more camera stuff
            camera.fov=53.638
        camera.speed=1
        --puts camera at a null named 'start'
        camera.pos.x=obj.start.pos.x
            camera.pos.y=obj.start.pos.y
            camera.pos.z=obj.start.pos.z
             --fog stuff
            fog.on=true
        fog.color.r=0
        fog.color.g=0
        fog.color.b=100
        --turn picker on
        engine.picker.on=true
            engine.picker.draw="nonstatic"
            engine.picker.scale.x=1600
            engine.picker.scale.y=1200
            engine.picker.clip.near=0
            engine.picker.clip.far=20
            --loads in the object...a textured cube
        level.load("wiz/wiz.lml")
        --puts the object at a specific position via null named 'cubestart'
        obj.wizcube.pos.x=obj.cubestart.pos.x
            obj.wizcube.pos.y=obj.cubestart.pos.y
            obj.wizcube.pos.z=obj.cubestart.pos.z
end --end of main funtion

function wizrotx()  --supposed to control the rotation of x
      obj.wizcube.rot.x=obj.wizcube.rot.x + 1
end

function wizroty()  --supposed to control the rotation of y
      obj.wizcube.rot.y=obj.wizcube.rot.y + 1
end

function wizrotz()  --supposed to control the rotation of z
      obj.wizcube.rot.z=obj.wizcube.rot.z + 1
end

function mercturn(event) --'mercturn' is what I wrote in the cubes action property in xsi
        if event=='mouse.change.y' then
           wizrotx()
           end
end


The way I'm trying to setup my game is that you dont actually control the camera, but instead you control objects that the camera is parented to.

its not working, so I know I'm going about it the wrong way...
but where?
pm  email   
jkaoz Posted: October 22, 2007, 11:36 AM quote

Newbie
*
Group: Testers
Member Id: 392
Joined: Oct 17 2007
Posts: 0
never mind I got it.
pm  email   
James Posted: October 23, 2007, 6:03 PM quote

LM Dev Team
**
Group: Admin
Member Id: 2
Joined: Sep 25 2004
Posts: 85
Yah, I d'no how you solved it but for future people who view this thread it should include something like this:

Code

function perframe()
obj.wizcube.rot.y=obj.wizcube.rot.y + mouse.change.x
end


The events that are sent to an object are limited to just mouseclicks right now afaik. A better event model will appear in the next version that allows you to create your own events.

-James
pm  email  www  aim  msn   
New Post New Topic New Poll

Options