- Joined
- Dec 23, 2005
- Messages
- 29
Hello, when using Megafyr's Advanced Third Person Camera script im getting a strange error which i think i've narrowed down to the camera bounds.
I've attached two videos showing how it should function (which works fine on a smaller map), and the issue which is when the map bounds are increased.
The system working
The system not working
At times, the system does not work at all, instead endlessly looping and becoming 'stuck' at the closest possible view point which you can see at the end of the second video.
Here is part of the initialization script which gets the camera bounds.
Here is the looping script where the camera is stuck trying to reach the maximum view distance
This is driving me bonkers as i can't really continue the map while this problem occurs.
Any help regarding the problems or a fix would make me super grateful.
Here are the scripts of the entire triggers
EDIT: This bug can be recreated easily in Megafyr's camera map i linked above by simply changing the map size to 256x256 and running it
I've attached two videos showing how it should function (which works fine on a smaller map), and the issue which is when the map bounds are increased.
The system working
The system not working
At times, the system does not work at all, instead endlessly looping and becoming 'stuck' at the closest possible view point which you can see at the end of the second video.
Here is part of the initialization script which gets the camera bounds.
Here is the looping script where the camera is stuck trying to reach the maximum view distance
This is driving me bonkers as i can't really continue the map while this problem occurs.
Any help regarding the problems or a fix would make me super grateful.
Here are the scripts of the entire triggers
Code:
//TESH.scrollpos=16
//TESH.alwaysfold=0
library TerrainPathability initializer Initialization
globals
constant integer TERRAIN_PATHING_DEEP = 1
constant integer TERRAIN_PATHING_SHALLOW = 2
constant integer TERRAIN_PATHING_LAND = 3
constant integer TERRAIN_PATHING_WALKABLE = 4
private unit Dummy = null
private constant integer DUMMY_UNIT_ID = 'h000'
private constant integer DUMMY_WINDWALK_ID = 'A000'
private constant player OWNING_PLAYER = Player(15)
private real WorldMinX = 0.
private real WorldMinY = 0.
endglobals
function IsTerrainPathingType takes real x, real y, integer terrainPathingType returns boolean
local boolean b = false
if terrainPathingType == TERRAIN_PATHING_DEEP then
set b = not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
elseif terrainPathingType == TERRAIN_PATHING_SHALLOW then
set b = not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
elseif terrainPathingType == TERRAIN_PATHING_LAND then
set b = IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY)
elseif terrainPathingType == TERRAIN_PATHING_WALKABLE then
call SetUnitPosition(Dummy, x, y)
set b = GetUnitX(Dummy) == x and GetUnitY(Dummy) == y and not (not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY))
call SetUnitX(Dummy, WorldMinX)
call SetUnitY(Dummy, WorldMinY)
endif
return b
endfunction
private function Initialization takes nothing returns nothing
set WorldMinX = GetRectMinX(bj_mapInitialPlayableArea)
set WorldMinY = GetRectMinY(bj_mapInitialPlayableArea)
set Dummy = CreateUnit(OWNING_PLAYER, DUMMY_UNIT_ID, 0., 0., 0.)
call UnitAddAbility(Dummy, DUMMY_WINDWALK_ID)
call UnitAddAbility(Dummy, 'Avul')
call IssueImmediateOrderById(Dummy, 852129)
call SetUnitX(Dummy, WorldMinX)
call SetUnitY(Dummy, WorldMinY)
endfunction
endlibrary
function SetCameraZ takes player whichPlayer, real z returns nothing
if ( GetLocalPlayer() == whichPlayer ) then
set z = GetCameraField(CAMERA_FIELD_ZOFFSET)+z-GetCameraTargetPositionZ()
call SetCameraField(CAMERA_FIELD_ZOFFSET,z,- 0.01)
call SetCameraField(CAMERA_FIELD_ZOFFSET,z,0.01)
endif
endfunction
Code:
//TESH.scrollpos=5
//TESH.alwaysfold=0
function Trig_Multiplayer_Camera_Actions takes nothing returns nothing
local boolean b
local integer i = 1
local location l
local real aoa
local real v
local real x
local real y
local real z
local real x1
local real y1
local real z1
loop
if udg_player[i] != null and (GetWidgetLife(udg_player[i]) > 0.405) then
set v = 25
set x = GetUnitX(udg_player[i])
set y = GetUnitY(udg_player[i])
set l = Location(x, y)
set z = GetLocationZ(l)
call RemoveLocation(l)
set x1 = x + 64 * Cos(GetUnitFacing(udg_player[i]) * bj_DEGTORAD)
set y1 = y + 64 * Sin(GetUnitFacing(udg_player[i]) * bj_DEGTORAD)
set l = Location(x1, y1)
set z1 = GetLocationZ(l)
call RemoveLocation(l)
call SetCameraZ(Player(i - 1), z + 128)
loop
set x1 = x - v * Cos(GetUnitFacing(udg_player[i]) * bj_DEGTORAD)
set y1 = y - v * Sin(GetUnitFacing(udg_player[i]) * bj_DEGTORAD)
set b = IsTerrainPathingType(x1, y1, TERRAIN_PATHING_WALKABLE)
if ((b == true) and (v < 525)) then
set v = v + 25
elseif ((b == false) or (v == 525)) then
exitwhen true
endif
endloop
if GetLocalPlayer() == Player(i - 1) then
call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(udg_player[i]), 0.50)
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, v, 0.08)
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, 330 + ((z1 - z) * 0.5), 0.32)
call SetCameraField(CAMERA_FIELD_FIELD_OF_VIEW, 120, 0)
call SetCameraField(CAMERA_FIELD_FARZ, 5000, 5)
call SetCameraTargetController(udg_player[i], 0, 0, false)
endif
exitwhen i == 1
set i = i + 1
endif
endloop
set l = null
endfunction
function InitTrig_Multiplayer_Camera takes nothing returns nothing
set gg_trg_Multiplayer_Camera = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Multiplayer_Camera, 0.04 )
call TriggerAddAction( gg_trg_Multiplayer_Camera, function Trig_Multiplayer_Camera_Actions )
endfunction
EDIT: This bug can be recreated easily in Megafyr's camera map i linked above by simply changing the map size to 256x256 and running it
Last edited: