• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Camera Pan Target? What chooses a camera target out of a group?

Status
Not open for further replies.
I have a multiplayer 3rd person altered melee map. The camera system is really smooth and I like it. It automatically disables the 3rd person view when peons or structures are selected and pans nicely between default view and the 3rd person view. However, if I select a group of units, the camera often follows one of the lesser units instead of the hero. What's worse is when I drag-select a group and there is a peon in the group, the camera stays in default, top-down view and does not pan to the warrior units. This creates a problem because it means that a player who takes a few peons into battle will be able to control his army more effectively than the other players stuck in 3rd person view. A friend recommended, I simply create a system that allows you to enable/disable the camera system at will, but I think players would just leave it disabled and miss the point of my map.

The point of my map, is that it looks really cool to fly over the trees and camps or run through the forest down at the units level. I have done a lot to make the playability decent. I don't want to loose the effect just so a player can have a tactical advantage.

I'm at work now but I can post the triggers if anyone thinks that will help. The real question is this. When a unit variable is set to [(My_Unit) = triggering unit] by the event trigger [Player(1) - selects a unit] and the order is given [Camera - pan camera to (My_Unit) (facing ((My_Unit) facing degrees) over 1.0 secs] AND you select multiple units in game, what decides which unit will be chosen as "My_Unit"? How can this be changed to ensure the highest ranking unit is the focus of the camera?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
What you can do is to start a timer when a unit is selected. The timer should expire after 0.00 or 0.01 seconds. Only start the timer if it is not running currently. When the timer expires, you loop through units selected by the player who selected the unit, and filter them in a way you need.

This way, if you select multiple units, all the selection events will run while the timer is running. Only after that you check selected units.
 
@Maker, I think your idea works but I can't really see it. Which triggers do I use for that?

@MaTija97, I like your idea too, but again I don't know the trigger that checks for unit levels. Also, for smoother gameplay, if there is a flying unit in a group, its best to lock on to that unit because it takes the most direct route to your destination and turns the camera the least.

Can either of you give me a quick example? Text is fine. As you can see I like to keep it simple. Less is more (aka imanoob).

OK, so here it is:

As you can see, I eliminate creeps and buildings. I want to be able to select peons, though not essential, and continue using the group in 3rd person cam with them in the group.

Trigger 1.

Sets unit Variable Goblin
Events
Time - Elapsed game time is 0.10 seconds
Player - Player 6 (Orange) Selects a unit
Conditions
Actions
Set unit6 = (Triggering unit)

Trigger 2.

Camera Locks unit goblin
Events
Time - Every 0.03 seconds of game time
Player - Player 6 (Orange) Selects a unit
Conditions
Actions
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
Animation - Change unit6 turn speed to 0.30
Camera - Pan camera for Player 6 (Orange) to (Position of unit6) over 1.00 seconds
Camera - Set Player 6 (Orange)'s camera Distance to target to 800.00 over 0.10 seconds
Camera - Set Player 6 (Orange)'s camera Angle of attack to 340.00 over 1.00 seconds
Camera - Set Player 6 (Orange)'s camera Height Offset to 285.00 over 0.10 seconds
Camera - Set Player 6 (Orange)'s camera Rotation to (Facing of unit6) over 0.70 seconds

Trigger 3.

Reset Camera Goblin
Events
Player - Player 6 (Orange) Presses the Down Arrow key
Conditions
Actions
Selection - Clear selection for Player 6 (Orange)
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
Trigger - Turn off Camera Locks unit goblin <gen>
Camera - Reset camera for Player 6 (Orange) to standard game-view over 0.00 seconds

Trigger 4.

Returns to Lock Goblin
Events
Player - Player 6 (Orange) Selects a unit
Conditions
Actions
Trigger - Turn on Camera Locks unit goblin <gen>

Trigger 6.

No Creep Camrea
Events
Player - Player 6 (Orange) Selects a unit
Conditions
(unit6 belongs to an enemy of Player 6 (Orange)) Equal to True
Actions
Trigger - Turn off Camera Locks unit goblin <gen>
Camera - Reset camera for Player 6 (Orange) to standard game-view over 1.00 seconds

Trigger 7.

No Building Camera Goblin
Events
Player - Player 6 (Orange) Selects a unit
Conditions
(unit6 is A structure) Equal to True
Actions
Trigger - Turn off Camera Locks unit goblin <gen>
Camera - Reset camera for Player 6 (Orange) to standard game-view over 1.00 seconds

Trigger 8.

Peon Camera Goblin
Events
Player - Player 6 (Orange) Selects a unit
Conditions
(unit6 is A peon-type unit) Equal to True
Actions
Trigger - Turn off Camera Locks unit goblin <gen>
Camera - Reset camera for Player 6 (Orange) to standard game-view over 1.00 seconds

*** HERE IS MY FAILED ATTEMPT ***

Peon Camera in Group
Events
Player - Player 6 (Orange) Selects a unit
Conditions
(Number of units in (Units currently selected by Player 6 (Orange))) Greater than 1
(unit6 is A peon-type unit) Equal to True
Actions
Trigger - Turn off Peon Camera Goblin <gen>
Trigger - Turn on Camera Locks unit goblin <gen>
***
Here's the map if you want to check it out, and try the triggers for yourself.

http://www.hiveworkshop.com/forums/pastebin.php?id=q9d7q0

***Expires in 7 days***
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
"Camera lock" does the same thing, and it looks bad. If I use camera lock, it does not change the problem of choosing the higher level unit in the group. For example, a footman will be the camera locked unit and the hero will just a member of the group. The problem is that "My_Unit" is being chosen out of a group automatically. I need to change that so that I can force it to choose a hero, flying unit, or the highest level unit in the group. Thats all. Thank you for trying but I think people are underestimating the issue. I have asked very experienced members this question and they are stumped as well. +rep for any effective solution.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
as said before use the condition to tell which unit u use the camera lock on.

here this may help u to better understand
event
unit is selected
condition
actions
set unitGroup = all units selected
pick every unit in group and do actions
if picked unit is hero
then
lock on target
call destroygroup
set udg_unitGroup = null
skip remaining actions
else
--- this doesnt go in else block put it after the loop--
pick random unit in unitGroup
lock camera to picked unit
--after that do this and that should work---
call destroygroup
set udg_unitGroup = null
 
  • Hero Camera in group Copy
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set Unit_group = (Units currently selected by Player 7 (Green))
      • Unit Group - Pick every unit in Unit_group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • Set unit_7 = (Picked unit)
            • Else - Actions
So I tried this but it still doesn't work for everything. It does seem to work (but I'm not sure) when I select a unit and a hero but with my other triggers to disable the lock for peons, creeps, and structures, it doesn't work. I guess maybe my problems are with those triggers now. I would still like to know what choses a unit out of a group when you drag-select and the variable is set to equal selected unit.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Try this


  • Selection Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set SelectHT = (Last created hashtable)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Custom script: set udg_i = GetHandleId(udg_SelectionTimers[bj_forLoopAIndex])
          • Hashtable - Save (Integer A) as 0 of i in SelectHT
          • Trigger - Add to Selection Filter <gen> the event (Time - SelectionTimers[(Integer A)] expires)
          • Trigger - Add to Select Unit <gen> the event (Player - (Player((Integer A))) Selects a unit)
  • Select Unit
    • Events
    • Conditions
    • Actions
      • Set i = (Player number of (Triggering player))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Not equal to (Load 0 of i in SelectHT)
          • (Remaining time for SelectionTimers[i]) Equal to 0.00
          • (Owner of (Triggering unit)) Equal to (Triggering player)
        • Then - Actions
          • Game - Display to Player Group - Player 1 (Red) for 1.00 seconds the text: start
          • Countdown Timer - Start SelectionTimers[i] as a One-shot timer that will expire in 0.01 seconds
        • Else - Actions
          • Custom script: call RemoveSavedHandle(udg_SelectHT, udg_i, 0)
  • Selection Filter
    • Events
    • Conditions
    • Actions
      • Custom script: set udg_i = LoadInteger(udg_SelectHT, GetHandleId(GetExpiredTimer()), 0)
      • Set plr = (Player(i))
      • Set grp = (Units currently selected by plr)
      • Unit Group - Pick every unit in grp and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • Set unit = (Picked unit)
              • Set i = (Player number of plr)
              • Hashtable - Save Handle Ofunit as 0 of i in SelectHT
              • Selection - Select unit for plr
            • Else - Actions


It only checks if there is a hero, you can change that logic in the if/then/else.
 

Attachments

  • Selection.w3x
    14 KB · Views: 24
you should loop through all the players when checking what to select. you also leak a group. you didnt follow the whole thing i posted above. You need to check if there is no hero in the group being selected. this is done in my example above.

Actually, this is working just fine now. I am concerned about the leak though. If you look at my triggers about you will see that I don't use "all player" commands, I will just set this up for each player. Also, I have a camera system that works better than locking, so I reset the variable to the hero rather than locking onto the hero. Also, I didn't want to add my entire camera system into the "select hero out of group" trigger. Hence, no I didn't follow your example to the T. But, it does work, so thank you +rep. Now, I need to see if it will work to select flying units over heroes. I also need to make it not reset camera when peons are selected in a group. I want it to reset when its only peons selected but not for mixed groups. But I guess that's a question for a different forum. Thank you, Thank you everyone.
 
Try this


  • Selection Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set SelectHT = (Last created hashtable)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Custom script: set udg_i = GetHandleId(udg_SelectionTimers[bj_forLoopAIndex])
          • Hashtable - Save (Integer A) as 0 of i in SelectHT
          • Trigger - Add to Selection Filter <gen> the event (Time - SelectionTimers[(Integer A)] expires)
          • Trigger - Add to Select Unit <gen> the event (Player - (Player((Integer A))) Selects a unit)
  • Select Unit
    • Events
    • Conditions
    • Actions
      • Set i = (Player number of (Triggering player))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Not equal to (Load 0 of i in SelectHT)
          • (Remaining time for SelectionTimers[i]) Equal to 0.00
          • (Owner of (Triggering unit)) Equal to (Triggering player)
        • Then - Actions
          • Game - Display to Player Group - Player 1 (Red) for 1.00 seconds the text: start
          • Countdown Timer - Start SelectionTimers[i] as a One-shot timer that will expire in 0.01 seconds
        • Else - Actions
          • Custom script: call RemoveSavedHandle(udg_SelectHT, udg_i, 0)
  • Selection Filter
    • Events
    • Conditions
    • Actions
      • Custom script: set udg_i = LoadInteger(udg_SelectHT, GetHandleId(GetExpiredTimer()), 0)
      • Set plr = (Player(i))
      • Set grp = (Units currently selected by plr)
      • Unit Group - Pick every unit in grp and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • Set unit = (Picked unit)
              • Set i = (Player number of plr)
              • Hashtable - Save Handle Ofunit as 0 of i in SelectHT
              • Selection - Select unit for plr
            • Else - Actions


It only checks if there is a hero, you can change that logic in the if/then/else.

This wasn't exactly what I meant. It removes non-heros from the group. However! Its exactly what I need for my peon problem. Thank you, Thank you, Thank you. +rep.
 
Status
Not open for further replies.
Top