Does anyone know of a good way to follow a unit smoothly with the camera? Currently, I have a loop that updates the unit and camera position 16 times per second. This works fine when the unit is moving slowly, but sucks when the unit has a higher velocity. Setting blend = true makes it somewhat better, but it's still not great. The problem I think may be because the unit and camera do not move together: first the unit gets moved, and for a moment the unit is off-center, and then the camera moves back in place.
I think maybe actors might offer a solution, as the (very sparse) Blizzard documentation says that they are asynchronous... so that they will not move before the camera is moved. Unfortunately, I'm not sure how to make actors that appear onscreen from Galaxy script. I can create my own actor model using ActorCreate, but it does not appear anywhere. I can get an actor from a unit, and move that around, but it suffers from the same problems as before (probably because the actor is still tied to the unit, and is thus synchronous). Any ideas?
PS: I've tried using CameraFollowUnitGroup, but my unit is moving too fast, and it just drifts off-center :(
Use Follow Unit group with Camera and convert the unit group to the unit you want to follow. If you want to reduce the follow lag you'll have to go into the cameras editor in the data editor and change the default game camera's follow speed.
Note, if you're using custom cameras then you wont be able to change their follow speed. You can only use the default camera. But if you want to change the camera height angle etc you can do that to the default camera in the data editor.
The unit movement is COMPLETELY SMOOTH when using an actor instead of the unit itself. Currently, I can create an actor using:
unitgroup group = UnitCreate(1, "Carrier", c_unitCreateIgnorePlacement, 1, Point(50, 50), 0);
unit ship = UnitGroupUnit(group, 1);
actorscope as = ActorScopeFromUnit(ship);
actor act = ActorFromScope(as, "::Main");
Looking at TriggerLibs/NativeLib, I have figured out how to move the actor and do all kinds of other cool stuff. The only problem is that I have to create a new unit for every such actor... I would prefer to just create the actor itself. There is a function in NativeLib that seems to do just that:
actor libNtve_gf_CreateModelAtPoint (string lp_model, point lp_position) {
// Variable Declarations
actor lv_a;
Unfortunately it doesn't do anything for me. I just can't seem to pass the right lp_model string. I've tried almost everything. Most of the time it just does nothing, but if you give it something ending in ".m3", such as "Assets\Units\Zerg\Mutalisk\Mutalisk.m3", the trigger crashes with an "unable to create actor" error. Perhaps I'm on the right track... any ideas?
Have a simple follow unit with camera function. Go to the Data editor and set the smooth time to a lower number (but not too low or it will be jittery), and there will be no noticeable delay and it will be nice and smooth.
Does anyone know of a good way to follow a unit smoothly with the camera? Currently, I have a loop that updates the unit and camera position 16 times per second. This works fine when the unit is moving slowly, but sucks when the unit has a higher velocity. Setting blend = true makes it somewhat better, but it's still not great. The problem I think may be because the unit and camera do not move together: first the unit gets moved, and for a moment the unit is off-center, and then the camera moves back in place.
I think maybe actors might offer a solution, as the (very sparse) Blizzard documentation says that they are asynchronous... so that they will not move before the camera is moved. Unfortunately, I'm not sure how to make actors that appear onscreen from Galaxy script. I can create my own actor model using ActorCreate, but it does not appear anywhere. I can get an actor from a unit, and move that around, but it suffers from the same problems as before (probably because the actor is still tied to the unit, and is thus synchronous). Any ideas?
PS: I've tried using CameraFollowUnitGroup, but my unit is moving too fast, and it just drifts off-center :(
@XPilot: Go
Use Follow Unit group with Camera and convert the unit group to the unit you want to follow. If you want to reduce the follow lag you'll have to go into the cameras editor in the data editor and change the default game camera's follow speed.
Note, if you're using custom cameras then you wont be able to change their follow speed. You can only use the default camera. But if you want to change the camera height angle etc you can do that to the default camera in the data editor.
The unit movement is COMPLETELY SMOOTH when using an actor instead of the unit itself. Currently, I can create an actor using:
unitgroup group = UnitCreate(1, "Carrier", c_unitCreateIgnorePlacement, 1, Point(50, 50), 0);
unit ship = UnitGroupUnit(group, 1);
actorscope as = ActorScopeFromUnit(ship);
actor act = ActorFromScope(as, "::Main");
Looking at TriggerLibs/NativeLib, I have figured out how to move the actor and do all kinds of other cool stuff. The only problem is that I have to create a new unit for every such actor... I would prefer to just create the actor itself. There is a function in NativeLib that seems to do just that:
actor libNtve_gf_CreateModelAtPoint (string lp_model, point lp_position) {
// Variable Declarations
actor lv_a;
// Variable Initialization
lv_a = null;
// Implementation
ActorCreate(null, "Model", (lp_model), null, "null");
lv_a = libNtve_gf_LastCreatedActor();
ActorSend(lv_a, libNtve_gf_ActorMsg1("SetPositionH", libNtve_gf_ConvertXYToString(PointGetX(lp_position), PointGetY(lp_position))));
ActorSend(lv_a, libNtve_gf_SetHeight(PointGetHeight(lp_position)));
return lv_a;
}
Unfortunately it doesn't do anything for me. I just can't seem to pass the right lp_model string. I've tried almost everything. Most of the time it just does nothing, but if you give it something ending in ".m3", such as "Assets\Units\Zerg\Mutalisk\Mutalisk.m3", the trigger crashes with an "unable to create actor" error. Perhaps I'm on the right track... any ideas?
The simplest and smoothest way i've found is simply putting a -pan camera to unit position- trigger in an infinite loop
Have a simple follow unit with camera function. Go to the Data editor and set the smooth time to a lower number (but not too low or it will be jittery), and there will be no noticeable delay and it will be nice and smooth.
Just worked on this same thing today and I wanted to document more clearly for anyone else.
The cleanest solution is simply to use built-in follow (ctr-shift-F) or create a trigger and edit the camera options in the data editor.
In the Cameras tab, select Default Camera and edit the following fields: