Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Getting a ghost object to look at the player
Getting a ghost object to look at the player
2003-01-28, 9:49 AM #1
I'm trying to get a camera to follow the player when he enters a sector, but my puny brain is far to small to understand the equation I need to do this! Here's what I have thus far (don't mind the stupid equation I tried [http://forums.massassi.net/html/smile.gif])

Code:
# Jedi Knight Cog Script
#
# Filename.COG
#
# Description
# 
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

sector		camersec		linkid=1
thing		camera			
thing		player			local

vector		playerpos		local

message 	startup
message	entered
message	pulse
message 	exited	

end

# ========================================================================================

code
startup:
	player = GetLocalPlayerThing();

entered:
	if(GetSenderRef() == camersec) {
		SetCameraFocus(0,camera);
		SetPulse(.01);
	}
	return;
pulse:
	playerpos = (GetThingPos(player) - GetThingPos(camera));
	SetThingLook(camera,playerpos);

exited:
	SetPulse(0);
	

# ........................................................................................

end


any help is appreciated!

------------------
Those who stare in the eyes of death and laugh will be the first to go.
Those who stare in the eyes of death and laugh will be the first to go.
2003-01-28, 10:12 AM #2
You were missing a few Return;'s that would cause code sections to run together.

Also I've always seen vector subtraction done using the VectorSub() cog verb.

Try this:

Code:
# Jedi Knight Cog Script
#
# Filename.COG
#
# Description
# 
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

sector     camersec     linkid=1
thing      camera
thing      player       local
vector     playerpos    local

message    startup
message    entered
message    pulse
message    exited

end

# ========================================================================================

code

startup:	
                player = GetLocalPlayerThing();
                Return;
entered:
                if(GetSenderRef() == camersec)
                {
                     SetCameraFocus(0,camera);
                     SetPulse(.01);
                }
                Return;
pulse:
                playerpos = VectorSub(GetThingPos(player), GetThingPos(camera));
                SetThingLook(camera,playerpos);
                Return;
exited:
                SetPulse(0);
                Return;

# ........................................................................................
end




[This message has been edited by The_New_Guy (edited January 28, 2003).]
- Wisdom is 99% experience, 1% knowledge. -

↑ Up to the top!