Explanation of video. I start out by transporting to the demon caves. After I am transported I want to be looking at the poor soul chained to the wall. A normal transport will not point the camera in that direction. It's either pointing to the floor or to another wall; I'm not sure. After a lot of trial and error I find a way to do this with script; but, I still have problems. I'm still not sure if I'm using the commands in the right way or the right order but I do get an initial result that is positive. Now if you take a look at the video.
I have the full code below. The problem is that when control is given back to the engine (being able to utilize the mouse view) we are immediately looking down at the floor so the player never sees what is in front of him. It can only be seen because I stopped it with a prompt. Mouse view control will be given back to the engine after pressing 'E'.
I was excited at first because I thought I had come up with script to actually "rotate" the player to look at a specified entity. The main part of it is the ability to get the positional 3D coordinates of the enity using x = GetEntityPositionX ( 319 ), y, and z (see code). 319 is the number of the entity for my map. I would have thought that setting the camera position and angle would have been sufficient and it would retain that position after using the necessary commands.
I also messed around with mouse xy coords to no avail. It always points to the floor.
Does anybody have any thoughts?
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- When Player Enters Zone from transport
local cam = 0
local x = 0
local y = 0
local z = 0
local mx = 0
local my = 0
local cx = 0
local cy = 0
local cz = 0
--local cax = 0
--local cay = 0
--local caz = 0
function point_player2entity_init(e)
SetActivated ( e, 0)
x = GetEntityPositionX ( 319 )
y = GetEntityPositionY ( 319 )
z = GetEntityPositionZ ( 319 )
end
function point_player2entity_main(e)
if g_Entity[e]['activated'] == 2 then
-- SetCameraAngle ( 0, cax, cay, caz )
SetCameraPosition ( 0, cx, cy, cz )
-- PositionCamera(cam,cx,cy,cz)
-- mx=MouseMoveX()
-- my=MouseMoveY()
mx=g_MouseX
my=g_MouseY
SetActivated ( e, 3)
elseif g_Entity[e]['activated'] == 3 then
Prompt("Press E to disable camera override mx="..mx.." my="..my)
if g_KeyPressE == 1 then
SetCameraOverride ( 0 )
PositionMouse(mx,my)
DeactivateMouse()
Destroy(e)
end
elseif g_Entity[e]['plrinzone']==1 then
PointCamera(0,x,y,z)
cx = GetCameraPositionX ( 0 )
cy = GetCameraPositionY ( 0 )
cz = GetCameraPositionZ ( 0 )
-- cax = GetCameraAngleX ( 0 )
-- cay = GetCameraAngleY ( 0 )
-- caz = GetCameraAngleZ ( 0 )
SetCameraOverride ( 3 )
SetActivated ( e, 2)
end
end
When in doubt -- C4 :heh, heh, heh:
-Jamie Hyneman