Could someone write a script that locks the camera in TA camera at a specific zoom and rotation. Also could the camera stay locked on a specific unit?
Thanks in advance.
Lua script request.
Moderator: Moderators
Re: Lua script request.
doesn't one of the keyboard shortcuts do that? T?smoth wrote:could the camera stay locked on a specific unit?
Re: Lua script request.
it has a specific camera angle etc... not the one I wanted.
- Blue_Falcon
- Posts: 155
- Joined: 16 Oct 2008, 18:54
Re: Lua script request.
You can change the angle using Ctrl+Mousewheel... Is that what you're after?
Re: Lua script request.
Don't post such an answer, or Smoth will raeg about how useless it is to post requests here again.
Re: Lua script request.
does that lock the camera to taview? does it set distance/angle? Does it set the camera to follow a unit? No, that is just turning the ta camera.Blue_Falcon wrote:You can change the angle using Ctrl+Mousewheel... Is that what you're after?
I would not make this request if I didn't have a good reason.
Re: Lua script request.
I think i know what this reason is.smoth wrote:does that lock the camera to taview? does it set distance/angle? Does it set the camera to follow a unit? No, that is just turning the ta camera.Blue_Falcon wrote:You can change the angle using Ctrl+Mousewheel... Is that what you're after?
I would not make this request if I didn't have a good reason.
I second this request, i want it too actually... you will received baked goods from both smoth AND me.
Re: Lua script request.
What is the unit you need the follow? How does widget (or gadget?) is given its ID? Will that unit change? Is it for a game where each player only has one unit? What if that unit die? Lock on death place or allow free roaming? The angle and height, hard coded or parametrable? Which way are passed the parameters? I assume some elasticity between the camera and unit movement would be nicer than stuttering?
From having tinkered with xyz's "spectator mode" widget, I know all you need is to periodically issue the commands:
Spring.SetCameraState({name=ta, mode=1, px=UnitX, py=0, pz=UnitZ, flipped=-1, dy=-0.9, zscale=0.5, height=999, dx=0, dz=-0.45}, TRANSITION_DURATION)
Spring.SelectUnitArray({UnitID})
Spring.SendCommands("track") -- "trackoff" is the command to stop it
Spring.SelectUnitArray({})
Or maybe if you're less conscious just:
Spring.SetCameraTarget(UnitX, 0, UnitZ, TRANSITION_DURATION)
So 90% of the code would be interfacing. And only you know what kind of interfacing you want. Because only you know the purpose and environnment of that Lua script.
From having tinkered with xyz's "spectator mode" widget, I know all you need is to periodically issue the commands:
Spring.SetCameraState({name=ta, mode=1, px=UnitX, py=0, pz=UnitZ, flipped=-1, dy=-0.9, zscale=0.5, height=999, dx=0, dz=-0.45}, TRANSITION_DURATION)
Spring.SelectUnitArray({UnitID})
Spring.SendCommands("track") -- "trackoff" is the command to stop it
Spring.SelectUnitArray({})
Or maybe if you're less conscious just:
Spring.SetCameraTarget(UnitX, 0, UnitZ, TRANSITION_DURATION)
So 90% of the code would be interfacing. And only you know what kind of interfacing you want. Because only you know the purpose and environnment of that Lua script.
Re: Lua script request.
Should maybe mention that I already gave him one.
Re: Lua script request.
No, it was him that should have mentionned.
Here's the one I'm using now:Notice how it compensate the unit speed and scale to weapon range. This does well for the purpose I wrote it for. However:
Is there any way to lock a camera, in the sense of making it obey Spring.SetCameraState and Spring.SetCameraTarget strictly and ignore any user input related to camera?
Because I want to do ingame cinematic intro to my mod, and I don't want my script to have to fight back against mouse pointer idling in the corner or user clicking on minimap.
Here's the one I'm using now:
Code: Select all
function gadget:Update()
local u=GetTheOne()
if u then
-- Focus on the unit
Spring.SelectUnitArray({},false)
local x,_,z=Spring.GetUnitPosition(u)
local _,v,paused=Spring.GetGameSpeed()
v = paused and 0 or v
local vx,_,vz=Spring.GetUnitVelocity(u)
local r=UnitDefs[Spring.GetUnitDefID(u)].maxWeaponRange
Spring.SetCameraState({name=ta, mode=1, px=x+9*v*vx,py=0, pz=z+9*v*vz, flipped=-1, dy=-0.9, zscale=0.5, height=2*r, dx=0, dz=-0.45},1)
else
if not Spring.GetSpectatingState() then
-- Focus on the start pos
Spring.SelectUnitArray({},false)
local x,y,z=Spring.GetTeamStartPosition(Spring.GetLocalTeamID())
Spring.SetCameraState({name=ta, mode=1, px=x, py=0, pz=z, flipped=-1, dy=-0.9, zscale=0.5, height=1200, dx=0, dz=-0.45},5)
end
end
end
Is there any way to lock a camera, in the sense of making it obey Spring.SetCameraState and Spring.SetCameraTarget strictly and ignore any user input related to camera?
Because I want to do ingame cinematic intro to my mod, and I don't want my script to have to fight back against mouse pointer idling in the corner or user clicking on minimap.