System Third Person Camera

quraji

zap
Reaction score
144
I decided to actually try it :p

Pretty sweet, works well.

And the camera bob after zooming in or out is a way cool little detail :thup:
 

xxxtrickyxxx

(o Y o)
Reaction score
64
if you dont mind me asking, how exactly does the Z eye position work? I myself and a few others are trying to figure out a correct way to initiate z height values for a camera on hills, terrain etc but to no avail it will not calculate correctly do to the way the terrain is formed or whatever technicality it mentioned on wc3 campaigns, but if this camera fixed that then I am curious as to how the zoffset field fixed this problem. I am not 100% sure how Z eye position works but from what I understand it is the current cameras height? So if you are doing the current zoffset field + locz + camera height above ground - eye z then arent you simply canceling out the current cameras z height so it would be the same as locz + cam height?

Any insight on this would be greately appriciated. As of now, I have to terrian deform everything via triggers for the Z height and camera to work correctly.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
JASS:
private function Actions takes nothing returns nothing
    call ForGroup(CameraUnits, function Movement)
endfunction


That function is called every 0.15 seconds.
CameraUnits, as you may guess from the name, is a unit group holding the current "camera units" of all players.

For each unit, it runs this:
JASS:
private function MovementKeep takes nothing returns nothing
    local unit u = GetEnumUnit()
    local location l = GetUnitLoc(u)
    if GetLocalPlayer() == GetOwningPlayer(u) then
        call PanCameraToTimed(GetUnitX(u), GetUnitY(u), Period)
        call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(u) + Rotate[GetPlayerId(GetOwningPlayer(u))], Period)
        call SetCameraField(CAMERA_FIELD_ZOFFSET, GetCameraField(CAMERA_FIELD_ZOFFSET) + GetLocationZ(l) + CameraHeight - GetCameraEyePositionZ(), Period)
        call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, Angle[GetPlayerId(GetOwningPlayer(u))], Period)
        call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, Distance[GetPlayerId(GetOwningPlayer(u))], Period)
    endif
    call RemoveLocation(l)
    set u = null
    set l = null
endfunction



> if GetLocalPlayer() == GetOwningPlayer(u) then

Obviously, only change the camera if it is your unit...

> call PanCameraToTimed(GetUnitX(u), GetUnitY(u), Period)

The unit probably moved, here we are following it.

The "Period" btw, is 0.15, which is the periodicity of the previous function.
It just looks way better if the camera adjusts over time instead of instantly.
Yes, even with 0.15 it makes a major difference.

Faster is possible.
Slower obviously not, as we would have to wait every now and then for the camera to catch up with the unit... :p


> call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(u) + Rotate[GetPlayerId(GetOwningPlayer(u))], Period)

Have the camera look at whatever direction the unit is currently looking at.
Offset by the current personal rotation (limited to + or - 90 degrees by default).


> call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, Angle[GetPlayerId(GetOwningPlayer(u))], Period)
> call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, Distance[GetPlayerId(GetOwningPlayer(u))], Period)

Distance and angle start out as angle = 345 (somewhat down at ground level) and distance = 600 (close enough).
They determine how close or far, or how "up" and "down" you are to or looking at your unit.
I.e. the current "zoom". Which may be different for each player.


> call SetCameraField(CAMERA_FIELD_ZOFFSET, GetCameraField(CAMERA_FIELD_ZOFFSET) + GetLocationZ(l) + CameraHeight - GetCameraEyePositionZ(), Period)

The mystery action would be this one :p


All the details:

- call SetCameraField(CAMERA_FIELD_ZOFFSET,

Height from the ground.

- GetCameraField(CAMERA_FIELD_ZOFFSET)

Whatever height the camera currently is at.

- GetLocationZ(l)

The height of the terrain at the position of the unit.

- CameraHeight

Some default value, set to 300.
It determines the seen height above the unit.
A camera at ground level makes no sense.
So, we take the height at the ground, add this...

- GetCameraEyePositionZ(), Period)

... and subtract this to adjust for "other mysterious terrain height settings that mess up everything".

The best example here would be a flying unit and a cliff.
Ever tried it?
The unit will not come near the cliff, then suddenly jump up and continue.
Instead, it will slowly, as it gets closer to the cliff, climb up then continue once over the cliff.

Turns out the game adds an additional height map, specifically for fliers. (Actually, also used when simply moving around the map, clearly visible at a lower angle)
When they follow that map, they will notice cliffs or other bumps or hills, or ...

Why subtract it?
Because we want the camera at a fixed height.
Well, not exactly fixed, but fixed at a constant height in relation to your unit.
I.e. if the unit goes up, so does the camera. Same for down.

Or, maybe like this:
The camera at a given point already has some height that depends on the terrain but is not the terrain that you see.
Since we don't want that, we remove that special height.


Result: walking up or down is no problem.

Actually, it's still a problem on extreme hills for example.
But, then again, they look terrible no matter what...
A half-decent terrain, even with ramps and cliffs, some ups and downs, stairs, ... works just fine.



On a related note, even you managed to mess up your map completely, up to the point where no one knows anymore what you're talking about,
it's still possible to use the above function in "normal" JASS.
Give it a name that is not used yet, remove the "private", and just call it periodically for a bunch of units.
 

Ryuu

I am back with Chocolate (:
Reaction score
64
Problem, yes, problem.

In almost 90% of every system I use, 'problem' comes up.

Take a look at my map, see that freaking problem of 288 JASS errors.

And yes, I'm using NewGen.
 

Attachments

  • DeadAce_Reloaded.w3x
    40.7 KB · Views: 313

Ryuu

I am back with Chocolate (:
Reaction score
64
Being a total noob to NewGen, I don't know there was this function.

But meh, I'm going to try it out.

EDIT: Err.. how do you do that? I viewed through the JassHelper menu but couldn't find it.

Could it be I'm actually using the wrong version.

While I download, please confirm that I'm not downloading for nothing.
 
S

Secondsight

Guest
First of all I really like this system! But second... I don't really know how to edit it a littlebit:(

I'm not very skilled at Jass or vJass so I'm afraid I have to ask this because I tried some things out already, but came to no better results.

I want to change it a bit, so the distance to the unit doesn't change when you press up or down. The thing I want is to always keep the distance 700 and let the up and down arrow's only change the AoA so you can watch above your unit too in some small area's where a camera behind the target would result into something very bad.

Any solutions for this?
 

Joker(Div)

Always Here..
Reaction score
86
Just edit the globals at the top to your likings...It doesn't require any JASSing skill at all, just uh...reading comprehension?
 
S

Secondsight

Guest
Just edit the globals at the top to your likings...It doesn't require any JASSing skill at all, just uh...reading comprehension?

I'm doing that like all the time. But it looks like the camera is not panned at the unit, but somewere behind the unit.:(
 

Dr.Jack

That's Cap'n to you!
Reaction score
109
Great system.
I suppose there is no easy way to control the Angle of Attack and smoothing factor? Also, no way to dynamically change camera's height?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Smoothing factor is something you usually only set once, around map init.

As for the others... well, there certainly is "a way".
Though, that would require some details on what that way is supposed to look like...
 

Dr.Jack

That's Cap'n to you!
Reaction score
109
> Though, that would require some details on what that way is supposed to look like...

Well my 'ideal camera ' would be: A) instead of having the camera placed exactly behind the unit, it would be placed slightly above it. Thus watching it from an upper point of you. B)If the unit's flying height increase so should the camera's (and obviously when the unit's flying height is decreasing so could the camera's).
 

Weegee

Go Weegee!
Reaction score
102
Is it possible to make the camera turn "smoother"?


sorry if this is "necroposting"
 

GooS

Azrael
Reaction score
154
Is it possible to make the camera turn "smoother"?


sorry if this is "necroposting"

If that was necroposting this most definately is, BUT is there a way to change Z angle, not height, but the way you look down/up on the unit, setting height would make me loose sight, lower is kinda the opposite of what I want, so angle.

Namnlös.jpg

^
|
Pvetty pictcha
 

Viikuna

No Marlo no game.
Reaction score
265
It is possible to change z angle, but then again, you need to change z height too, or the camera goes inside the ground.
 

GooS

Azrael
Reaction score
154
It is possible to change z angle, but then again, you need to change z height too, or the camera goes inside the ground.

EDIT: Sry for being a retard.... after taking a closer look :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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