HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

I lost control over my camera

05-12-2010, 02:09 AM#1
DanThanh
-Sometimes my camera just automatically pan to a black area on the map and i lost track of my Hero. How nasty it is, do you have any clue about the cause ?
05-12-2010, 05:33 AM#2
Tot
code?
05-12-2010, 01:01 PM#3
DanThanh
For panning camera, i always use this:

Collapse JASS:
local unit u = GetTriggerUnit()
local player p = GetOwningPlayer(u)

call SetUnitPosition(u, GetRectCenterX(gg_rct_JinPort), GetRectCenterY(gg_rct_JinPort))
if (GetLocalPlayer() == p) then
  call PanCameraToTimed(GetRectCenterX(gg_rct_JinPort),GetRectCenterY(gg_rct_JinPort), 0.)
endif
05-12-2010, 04:26 PM#4
Tot
Quote:
Originally Posted by DanThanh
For panning camera, i always use this:

Collapse JASS:
local unit u = GetTriggerUnit()
local player p = GetOwningPlayer(u)

call SetUnitPosition(u, GetRectCenterX(gg_rct_JinPort), GetRectCenterY(gg_rct_JinPort))
if (GetLocalPlayer() == p) then
  call PanCameraToTimed(GetRectCenterX(gg_rct_JinPort),GetRectCenterY(gg_rct_JinPort), 0.)
endif

if you want to pan a camera to an position, use
Collapse JASS:
globals
unit array dummies
boolean array panned
endglobals

function PanCam takes real x, real y, player p returns nothing
local integer id=GetPlayerId(p)
if panned[id] then
call SetUnitX(dummies[id],x)
call SetUnitY(dummies[id],y)
else
if dummies[id]==null then
//create new
set dummies[id]=CreateUnit(Player(15),'hpea',x,y,0.0)
call PauseUnit(dummies[id],true)
call ShowUnit(dummies[id],false)
call UnitAddAbility(dummies[id],'Aloc')
else
//move old
call SetUnitX(dummies[id],x)
call SetUnitY(dummies[id],y)
endif
set panned[id]=true
if GetLocalPlayer()==p then
call SetCameraTargetController(dummies[id],0.0,0.0,true)
endif
endif
endfunction

function UnpanCam takes player p returns nothing
if GetLocalPlayer()==p then
call SetCameraTargetController(null,0.0,0.0,true)
set panned[id]=false
endif
endfunction
05-14-2010, 01:44 AM#5
_too
Quote:
Originally Posted by Tot
if you want to pan a camera to an position, use
Collapse JASS:
globals
unit array dummies
boolean array panned
endglobals

function PanCam takes real x, real y, player p returns nothing
local integer id=GetPlayerId(p)
if panned[id] then
call SetUnitX(dummies[id],x)
call SetUnitY(dummies[id],y)
else
if dummies[id]==null then
//create new
set dummies[id]=CreateUnit(Player(15),'hpea',x,y,0.0)
call PauseUnit(dummies[id],true)
call ShowUnit(dummies[id],false)
call UnitAddAbility(dummies[id],'Aloc')
else
//move old
call SetUnitX(dummies[id],x)
call SetUnitY(dummies[id],y)
endif
set panned[id]=true
if GetLocalPlayer()==p then
call SetCameraTargetController(dummies[id],0.0,0.0,true)
endif
endif
endfunction

function UnpanCam takes player p returns nothing
if GetLocalPlayer()==p then
call SetCameraTargetController(null,0.0,0.0,true)
set panned[id]=false
endif
endfunction

There was a small mistake in code.

Collapse JASS:
function UnpanCam takes player p returns nothing
local integer id=GetPlayerId(p)
if GetLocalPlayer()==p then
call SetCameraTargetController(null,0.0,0.0,true)
set panned[id]=false
endif
endfunction
05-14-2010, 08:10 AM#6
Tot
Quote:
Originally Posted by _too
There was a small mistake in code.

Collapse JASS:
function UnpanCam takes player p returns nothing
local integer id=GetPlayerId(p)
if GetLocalPlayer()==p then
call SetCameraTargetController(null,0.0,0.0,true)
set panned[id]=false
endif
endfunction

yup, should be
Collapse JASS:
function UnpanCam takes player p returns nothing
if GetLocalPlayer()==p then
call SetCameraTargetController(null,0.0,0.0,true)
endif
set panned[GetPlayerId(p)]=false
endfunction
05-15-2010, 09:39 AM#7
DanThanh
OOps, thanks for your help ^^
But what's wrong with my code? because it works normally ingame. I don't know if it causes that naughty bug.
05-15-2010, 01:18 PM#8
Tot
Quote:
Originally Posted by DanThanh
OOps, thanks for your help ^^
But what's wrong with my code? because it works normally ingame. I don't know if it causes that naughty bug.

maybe something with camera-distance or clipping