• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Adapt Camera Height to Ground?

Status
Not open for further replies.
Level 2
Joined
Sep 2, 2006
Messages
19
Hi ;)

Im working on a first person RPG and i wanted to know if itis possible to adapt the camera to the ground? Until now it goes right through the floor everytime theres a hill or something...

I would be happy about suggestions !!
 

Attachments

  • RPG.jpg
    RPG.jpg
    82.5 KB · Views: 245
Level 8
Joined
Feb 20, 2007
Messages
338
Sadly there is no "easy" trigger.

What you will need to do is have regions and either raise the camera, or increase the Angle of attack for those regions.

Depending on your aoa, you might get away with increasing the distance to the target.

For really steep hills you might want to stack regions, a smaller one inside a larger one, gradually increasing the height, aoa or distance as the unit moves up/into the area.
 
Actually there is...

  • Melee Initialization
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Set CameraPoint = (Position of (YOUR UNIT HERE))
      • Set CameraHeigh = 100.00
      • Custom script: call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_ZOFFSET, ( udg_CameraHeight + GetLocationZ(udg_CameraPoint) ), 0.03 )
Just set the CameraHeight to what you want and CameraPoint to the point where the camera is (position of the players unit in this case)

oh and CameraHeight must be a "real" variable and CameraPoint a "point" variable
 
Level 2
Joined
Sep 2, 2006
Messages
19
thx for the quick help, but the trigger doesnt work, theres no error though...

i changed Player (0) to Player (1), but it still says "Name requested" (or something, its german :D), its a compilation error

the regions suggestion is very hard to realize, and small waves in the ground cant be considered. but thx ;)
 
Level 11
Joined
Aug 25, 2006
Messages
971
Wow... I can't believe that works! (I posted the map I used to test it at the bottom)

I can't believe it works because there's not GetUnitZ native. Theres GetUnitX and GetUnitY. Oh and remember to clean the point! (I didn't clean it in mine either) If you don't clean that memory leak it'll leak every .04 seconds. Which is very very bad.
 

Attachments

  • UnitZ.w3x
    13.4 KB · Views: 51
Last edited:
Level 2
Joined
Sep 2, 2006
Messages
19
Well could you plz post the code you used? I copied Kitabake's code, but theres an error everytime i want to test...
 
Level 12
Joined
Aug 18, 2006
Messages
1,193
ehm, instead of a code, why not use
  • Camera - Pan camera for Player 1 (Red) to (Center of (Playable map area)) with height 0.00 above the terrain over 0.00 seconds
i might not have that much experience with cameras, but anyway?
 
Level 8
Joined
Feb 20, 2007
Messages
338
Ah, what a lovely way to do it.

I'm sorry for my previous reply, I have asked this question on this and other forums and have always been told it has to be done by regions.

Of course now this means I have to go back and undo many, many, many regions on 6 maps of my campaign I am working on....

:week:
 
it doesnt really matter, since CameraHeight is a variable name

you can name it Point, and it would still work as a Real variable :p
Actually it does matter as it is used in the custom script. If the variable name and the name used in custom script do not match, it doesn't work.
(Well of course you could have left the variable name to "CameraHeigh" and then changed the custom script instead...)

Ah, what a lovely way to do it.

I'm sorry for my previous reply, I have asked this question on this and other forums and have always been told it has to be done by regions.
No need to be sorry since I haven't seen this way on the forums either.
I had to find it out myself by testing and experimenting many times when I was doing a projectile system of mine.
 
Level 8
Joined
Feb 20, 2007
Messages
338
Alright then, Kitabatake.

I tried the custom script in my map.

I have a couple of "issues".

Setting the variable CameraHeight at 100 leads to the camera being way up in the air, to where you can not see the unit (Picture 1)

Setting CameraHeight to -130 gets the camera just about right behind the selected unit (Picture 2) on relatively flat areas.

However when going down or up (Pictures 3 and 4) either the camera shows the skybox below, or it climbs faster/higher than the unit.

Climbing the hill by the time I get to the top of the hill the camera is way up in the air.

This is how I am using your Jass functions:

  • Events
    • Time - Every 0.50 seconds of game time
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • CamSetting Equal to 0
    • Then - Actions
      • -------- --------Ground Units not buildings --------
      • Set CameraHeight = 100.00
      • Set CameraPoint = (Position of Selected_Unit)
      • Custom script: call SetCameraFieldForPlayer( Player(8), CAMERA_FIELD_ZOFFSET, ( udg_CameraHeight + GetLocationZ(udg_CameraPoint) ), 0.50 )
      • Custom script: call RemoveLocation( udg_CameraPoint )
      • -------- * --- * --------
      • Camera - Set Player 9 (Gray)'s camera Angle of attack to 338.00 over 0.50 seconds
      • Camera - Set Player 9 (Gray)'s camera Field of view to 500.00 over 0.50 seconds
      • Camera - Set Player 9 (Gray)'s camera Roll to 0.00 over 0.50 seconds
      • Camera - Set Player 9 (Gray)'s camera Distance to target to 190.00 over 0.50 seconds
      • Camera - Set Player 9 (Gray)'s camera Far Z to 6500.00 over 0.50 seconds
    • Else - Actions
Am I doing something wrong here or is there limits to what calling the Z can do?

Selected_Unit is set to the selected unit. If the player selects a group of units the last one selected is "it".
 

Attachments

  • CamHelpPlease1.jpg
    CamHelpPlease1.jpg
    70.1 KB · Views: 90
  • CamHelpPlease2.jpg
    CamHelpPlease2.jpg
    74.4 KB · Views: 94
  • CamHelpPlease3.jpg
    CamHelpPlease3.jpg
    73.5 KB · Views: 112
  • CamHelpPlease4.jpg
    CamHelpPlease4.jpg
    70.1 KB · Views: 96
Alright then, Kitabatake.

I tried the custom script in my map.

I have a couple of "issues".

Setting the variable CameraHeight at 100 leads to the camera being way up in the air, to where you can not see the unit (Picture 1)
Yes 100 was only an example that you could set to whatever you want according to your camera system.

Try setting CameraHeight to 0 and test if it works properly
 
Status
Not open for further replies.
Top