View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001580 | FSSCP | scripting | public | 2008-01-18 07:57 | 2008-03-23 12:19 |
Reporter | Nuke | Assigned To | WMCoolmon | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 3.6.9 | ||||
Summary | 0001580: subsystem:fireWeapon() fires in the wrong diection, possible matrix order issue | ||||
Description | not sure if this is a bug or a feature. but if i change a turrets Orientation or GunOrientation from scripting, and then call fireWeapon(), the turret fires in the wrong direction. it works fine if the ship is at its default orientation, if you turn then it throws the aim off. i think this has something to do with the way it builds the matrix for the weapon orientation. when it builds the matrix for the resulting weapon firing angle, it looks like its using base orientation * barrel orientation. but i think it needs to be ship orientation * base orientation * barrel orientation. also when i was putting the example together i discovered that you could no longer write to orientation.p/orientation[p]/orientation['p'] values | ||||
Additional Information | heres a simple test, fly a medusa in an empty mission with no enemies. use the mouse to control the turret. then turn 90 degrees in any direction and try to fire. the shot is going where it would go if you were in your default orientation. the internal firing matrix doesnt take ship orientation into account. #Global Hooks $GameInit: [ ------------------------------- ----------screen vars---------- ------------------------------- w = gr.getScreenWidth() h = gr.getScreenHeight() cx = w/2 cy = h/2 wf = 0 hf = 0 hires = false if w >= 1024 then wf = w / 1024 hf = h / 768 hires = true else wf = w / 640 hf = h / 480 hires = false end ---------------------------- ----------controls---------- ---------------------------- mousejoy = function() --mousejoy function, short version local X = io.getMouseX() local Y = io.getMouseY() if hires then X = (X / 511.5) - 1 Y = (Y / 383.5) - 1 else X = (X / 319.5) - 1 Y = (Y / 239.5) - 1 end return X, Y end ] $Simulation: [ X,Y = mousejoy() ship = mn.Ships["Alpha 1"] if cam == nil then cam = mn.createCamera("guncam") end if ship:isValid() then tsub = ship["turret01a"] if tsub:isValid() then pori = ba.createOrientation(-Y * ba.getFrametime(),0,0) tsub.GunOrientation = tsub.GunOrientation * pori --incriment barrel pitch in some direction if tsub.GunOrientation['p'] < 0 then tsub.GunOrientation = ba.createOrientation(0,0,0) --limit the barrels angle of motion elseif tsub.GunOrientation['p'] > 1.5 then --i can read .p tsub.GunOrientation = ba.createOrientation(1.5,0,0) --but for some reason i cant seem to change .p end hori = ba.createOrientation(0,0,(X * ba.getFrametime())) --rotate the base tsub.Orientation = tsub.Orientation * hori if io.isMouseButtonDown(MOUSE_LEFT_BUTTON) then --fire it tsub:fireWeapon() end if cam:isValid() then gori = tsub.GunOrientation --camera code gori.p = gori.p - math.pi*0.5 tori = ship.Orientation * tsub.Orientation * gori cam:setOrientation(tori) cam:setPosition(ship.Position + ship.Orientation:unrotateVector(tsub.Position) ) mn.setCamera(cam) end end else cam = nil end ] #end | ||||
Tags | No tags attached. | ||||
|
Fixed in trunk. The problem was actually that the turret's orientation was being rotated by the base and gun angles after the turret had been rotated into world space via the object's orientation. I had to break open one of the turret functions to get it to rotate properly. |
Date Modified | Username | Field | Change |
---|---|---|---|
2008-01-18 07:57 | Nuke | New Issue | |
2008-01-18 07:57 | Nuke | Status | new => assigned |
2008-01-18 07:57 | Nuke | Assigned To | => WMCoolmon |
2008-03-23 12:19 | WMCoolmon | Note Added: 0009018 | |
2008-03-23 12:19 | WMCoolmon | Status | assigned => resolved |
2008-03-23 12:19 | WMCoolmon | Resolution | open => fixed |