Following Camera

rodge_002

New Member
Reaction score
4
I locked a camera onto a unit.

However, when the unit goes up into a higher level terrain, the camera doesn't go with it... I really don't like this.

Is there a way to make the camera follow the character and adjust its height when the character does too?
 

xxxtrickyxxx

(o Y o)
Reaction score
64
goes in your custom scripts section
JASS:
function SetCameraZ takes real z returns nothing
    set z = GetCameraField(CAMERA_FIELD_ZOFFSET)+z-GetCameraTargetPositionZ()
    call SetCameraField(CAMERA_FIELD_ZOFFSET,z,- 0.01)
    call SetCameraField(CAMERA_FIELD_ZOFFSET,z,0.01)
endfunction


run a .10 or .01 trigger that will pick the player and create a location of the unit that is locked on to.

set unit location
set locz = z of unit location
setcameraz takes care of the rest
remove unit location

the 400 at the end is for you to change, if you want the camera to be higher or lower depends on you.
Code:
Untitled Trigger 004
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Set Unit_Loc= (Position of Unit)
        Custom script:   set udg_LocZ=GetLocationZ(udg_Unit_Loc)
        Custom script:   call SetCameraZ(udg_LocZ+400)
        Custom script:   call RemoveLocation (udg_Unit_Loc)
 

deathreaper9

New Member
Reaction score
0
xxxtrickyxxx
That doesn't seem to work for me, but then, I'm not sure where to put it exactly. Perhaps you can take a look at the system that I attached.. It's somewhat a modified of a camera system I used from Hiveworkshop. Maybe you can help me?
 

Attachments

  • AM v2.w3x
    86.2 KB · Views: 151

mango

Member
Reaction score
0
I apologize for bumping someone else's thread, but I'm having the EXACT same problem and didn't think there needed to be 2 seperate threads. I haing trouble understanding which variables I need to declare to make this function work, I keep getting several errors:

-cannot convert real to location
-bad types for binary operator
-undeclared function SetCameraZ
-undeclared variable z

I hope this makes more sense to someone else :(
 

bOb666777

Stand against the ugly world domination face!
Reaction score
117
You obviously don't have a SetCameraZ function... :p
 

xxxtrickyxxx

(o Y o)
Reaction score
64
open up the am v2 map i attached and look at the function located at the mapname.w3x in the triggers and how the custom script is calling the function. also make sure you have the appropriate variables created such as the locz location where the z is being calculated before the camera is altered.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top