HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Rpg Like Camera -

09-02-2009, 07:40 PM#1
Mendel
Hi :D,
after a few days and a few questions here in the forum, i have finally done my rpg like camera :D
This camera is a 3rd person similiar to wow( world of warcraft)

Futures:
  • Camera is affacted by ground level, wich means if the hero goes up - so is the camera.
  • Ability to Rotate camera right, left. Using the arrow keys.
  • Ability to change angle of attack up, down. Using the arrow keys.
  • A smooth movment.
  • The distancce to target is changeable, by Typing: "V [number from 0 to 9999].
    And also the height is affacted by the distance wich makes your hero always visible, even if you put 3000 distance, unless your already seeing black :D.


Also works by variable: Hero[1~6] (unit variable).
so to add this to map, you can easly import it and just set each player's hero. and it all works.
Here are the codes:

CameraScript:
Collapse JASS:
function SetCameraZ takes real z, player p returns nothing
    if GetLocalPlayer() == p then
       set z = GetCameraField(CAMERA_FIELD_ZOFFSET)+z-GetCameraTargetPositionZ()
       call SetCameraField(CAMERA_FIELD_ZOFFSET,z,- 0.01)
       call SetCameraField(CAMERA_FIELD_ZOFFSET,z,0.01)
    endif
endfunction

The Main triggers:

Trigger:
OverAll
Collapse Events
Time - Every 0.10 seconds of game time
Conditions
Collapse Actions
Collapse Player Group - Pick every player in (All players) and do (Actions)
Collapse Loop - Actions
Camera - Lock camera target for (Picked player) to Hero[(Player number of (Picked player))], offset by (0.00, 0.00) using Default rotation
Camera - Set (Picked player)'s camera Distance to target to (Real(CameraDistance[(Player number of (Picked player))])) over 0.10 seconds
Camera - Set (Picked player)'s camera Angle of attack to (Real(CameraAngle[(Player number of (Picked player))])) over 0.10 seconds
Camera - Set (Picked player)'s camera Rotation to ((Facing of Hero[(Player number of (Picked player))]) + (Real(CameraRotation[(Player number of (Picked player))]))) over 0.50 seconds
Set Loc[(Player number of (Picked player))] = (Position of Hero[(Player number of (Picked player))])
Custom script: set udg_TerrainHeight[(GetPlayerId(GetEnumPlayer()))+1] = GetLocationZ(udg_Loc[(GetPlayerId(GetEnumPlayer()))+1])
Set CameraHeight[(Player number of (Picked player))] = ((Integer(TerrainHeight[(Player number of (Picked player))])) + (CameraDistance[(Player number of (Picked player))] / 4))
Custom script: call SetCameraZ (udg_CameraHeight[GetPlayerId(GetEnumPlayer())+1] , Player(GetPlayerId(GetEnumPlayer())))

Trigger:
Distance
Collapse Events
Player - Player 1 (Red) types a chat message containing v as A substring
Player - Player 2 (Blue) types a chat message containing v as A substring
Player - Player 3 (Teal) types a chat message containing v as A substring
Player - Player 4 (Purple) types a chat message containing v as A substring
Player - Player 5 (Yellow) types a chat message containing v as A substring
Player - Player 6 (Orange) types a chat message containing v as A substring
Conditions
Collapse Actions
Set CameraDistance[(Player number of (Triggering player))] = (Integer((Substring((Entered chat string), 3, 6))))

*it's not all triggers, there is also the triggers for controling the camera movment using the arrow keys, sadly it's too much to add and i am short on time at the moment.



i need to credit some people for this, with out them i couldnt have done it, i don't remember who they are exactly so, if u do see this and u know u helped me, just tell me, i'll rep you and write ur name down here :D.

I am interested in making an rpg with this camera, if some one is interested too, tell me.

Link to map, check it out :D:
Attached Files
File type: w3xRpg_Work.w3x (151.2 KB)
09-02-2009, 08:14 PM#2
Anitarf
You'd probably get more replies if you posted your code instead of the map.
09-03-2009, 03:39 AM#3
Mendel
I Did, did u see it?
09-03-2009, 04:19 AM#4
Fledermaus
Looks like a GUI version of Oppi's except way less flexible, and in GUI.

Just tested and it's way worse, locking camera to target is so skippy compared to panning to them. It also doesn't have any anti-clipping which results in lameness like this
Hidden information:
Zoom (requires log in)
(the hero is at the bottom of the cliff)

Also, you can't click on the minimap to move there because of the lock-to-hero.

Not to sound like a dick but:
"Camera is affacted by ground level, wich means if the hero goes up - so is the camera." I didn't notice this at all (see screen shot)

"A smooth movment." You're joking right?

"Also works by variable: Hero[1~6] (unit variable)." Kinda silly that you have to use that variable, guess I'm just too used to Oppi's one.
Attached Images
File type: jpgcamera.JPG (193.1 KB)
09-03-2009, 10:48 AM#5
Opossum
Quote:
Originally Posted by Fledermaus
Looks like a GUI version of Oppi's except way less flexible, and in GUI.

Just tested and it's way worse, locking camera to target is so skippy compared to panning to them. It also doesn't have any anti-clipping which results in lameness like this

Also, you can't click on the minimap to move there because of the lock-to-hero.

Not to sound like a dick but:
"Camera is affacted by ground level, wich means if the hero goes up - so is the camera." I didn't notice this at all (see screen shot)

"A smooth movment." You're joking right?

"Also works by variable: Hero[1~6] (unit variable)." Kinda silly that you have to use that variable, guess I'm just too used to Oppi's one.
Yeah, I rock.

Actually the cam looks pretty good for a GUI camera. Reminds me of the old days when OppiCam was still in GUI. It's the first time I see Toadcop's anti-smoothing function in action though and I have to say it's kinda jerky. When walking steep hills the camera is a bit laggy which doesn't look very natural. This is how I did it:
Collapse JASS:
        call MoveLocation(Loc, newx, newy)
        call SetCameraField(CAMERA_FIELD_ZOFFSET, GetCameraField(CAMERA_FIELD_ZOFFSET) + GetLocationZ(Loc) + Z_OFFSET + GetUnitFlyHeight(Unit[p]) - GetCameraTargetPositionZ(), duration)
Keep up the work. The camera system is what I learned Jass with and so will you.
09-03-2009, 11:03 AM#6
Viikuna-
Quote:
It's the first time I see Toadcop's anti-smoothing function in action though and I have to say it's kinda jerky

Ive been having some problems with it too. Although, those problems might have been partly caused by too big far z values.
09-03-2009, 11:07 AM#7
Opossum
Quote:
Originally Posted by Viikuna-
Ive been having some problems with it too. Although, those problems might have been partly caused by too big far z values.
There shouldn't be any problems with far z other than it being capped at 10000 and causing a lot of lag at low camera angles.
09-03-2009, 11:28 AM#8
Mendel
Opossum, thx :]
Could u tell me exactly what to do to make it better?, i don't know jass at all :D
that thing u wrote in jass doesn't tell me anything hehe ^^
09-03-2009, 04:03 PM#9
Opossum
To make it really good you should learn Jass. I won't teach you that as it's quite a goal to achieve.
Considering the camera's offset you should replace your jass function with this:
Collapse JASS:
function SetCameraZ takes real z, player p returns nothing
    if GetLocalPlayer() == p then
        call SetCameraField(CAMERA_FIELD_ZOFFSET, GetCameraField(CAMERA_FIELD_ZOFFSET) + udg_TerrainHeight[(GetPlayerId(p))+1] + z + GetUnitFlyHeight(udg_Hero[p]) - GetCameraTargetPositionZ(), 0.1)
    endif
endfunction
You can leave out the yellow part if you don't want the unit's flying height to be added.
Maybe Toadcop's version will not look that jerky if you use a bigger value than 0.01 for the panning duration.

Also you are leaking a location in your periodic trigger which will - in a 0.1 periodic trigger - cause the game to lag after some time. You should replace this line:
Trigger:
Set Loc[(Player number of (Picked player))] = (Position of Hero[(Player number of (Picked player))])
with this:
Collapse JASS:
call MoveLocation(udg_Loc[GetPlayerId(GetEnumPlayer())+1], GetUnitX(udg_Hero[GetPlayerId(GetEnumPlayer)]), GetUnitY(udg_Hero[GetPlayerId(GetEnumPlayer)]))

And this is exactly why I said you will learn Jass by improving this system.
09-03-2009, 04:40 PM#10
Mendel
I need the 1.24 patch for this?
Collapse JASS:
call MoveLocation(udg_Loc[GetPlayerId(GetEnumPlayer())+1], GetUnitX(udg_Hero[GetPlayerId(GetEnumPlayer)]), GetUnitY(udg_Hero[GetPlayerId(GetEnumPlayer)]))

cause i did replace and it just moves me to menu
09-03-2009, 04:56 PM#11
Opossum
My mistake:
Collapse JASS:
call MoveLocation(udg_Loc[GetPlayerId(GetEnumPlayer())+1], GetUnitX(udg_Hero[GetPlayerId(GetEnumPlayer())]), GetUnitY(udg_Hero[GetPlayerId(GetEnumPlayer())]))
09-03-2009, 05:24 PM#12
Mendel
ok, i did but now, the camera doesn't move on the Z line, :\
Edit: what does this movelocation do?
09-03-2009, 05:38 PM#13
Opossum
Instead of creating a new location it just moves an existing location to new coordinates. Doing this, you don't have to remove locations to avoid leaks.

Quote:
ok, i did but now, the camera doesn't move on the Z line, :\
What do you mean by "move on the Z line"? It might be possible that you need to initialize the location first:
Trigger:
Set Loc = (Point(0.00, 0.00))
Put that somewhere in your initialization trigger.
09-03-2009, 06:27 PM#14
Mendel
he, i found the problem, we needed to put +1 in that getunitx and getunity arrays
Collapse JASS:
call MoveLocation(udg_Loc[GetPlayerId(GetEnumPlayer())+1], GetUnitX(udg_Hero[GetPlayerId(GetEnumPlayer())+1]), GetUnitY(udg_Hero[GetPlayerId(GetEnumPlayer())+1]))
09-03-2009, 06:51 PM#15
Viikuna-
Man, I just wish that destructibles had vertex color, so I could use them instead of doodads and then turn everything transparent that comes between the camera unit and the camera..

In jass player ides go from 0 to 11.

Player(0) is red, Player(1) is blue, etc.