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,494
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: 304

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,494
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.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top