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 → Immobilizing the Player, or Making a Thing Look at Something, or Getting a Vector...
Immobilizing the Player, or Making a Thing Look at Something, or Getting a Vector...
2004-11-29, 8:48 PM #1
Ok, here's the sitch: I'm trying to help Spiral with his new project. He needs a cog to allow a player to use a camera system. So far so good, except the player can still spin while looking through the camera, so he can move his aimpoint off the surface that activates the cog.

I've tried setActorFlags(), but the two flags I've tried either allow the player to spin, or don't allow him to even activate the surface.

So my next idea was to run a pulse to set the player's look vector to always be looking at the surface that is used to activate the cog. But I cannot figure out how to get a vector that points from one thing to another. Is it possible?

Please help. Our progress hinges on your help. :)
KOP_blujay
Just dancin'...and singin'...in the Force.
2004-11-29, 8:54 PM #2
You can just have him add a ghost at the consoles position and in the camera cog do SetThingLook(player, ghost);.

If you really just want to find the vector between 2 things, then use
Dir = VectorSub(vec1, vec2);
Len = VectorLen(Dir);
Dir is the vector between the two points, Len is the distance.
</sarcasm>
<Anovis> mmmm I wanna lick your wet, Mentis.
__________
2004-11-29, 8:57 PM #3
Well, here's some chase cam code (activated from a switch) I wrote some time ago. I imagine the camera part of it could be changed.
Code:
# Jedi Knight Cog Script
#
# qm_spectator.cog
#
# Let's a player spectate other players by activating a switch.
#
# [QM]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved

flags=0x240

symbols

surface     spectate_button

thing       player=-1                        local
thing       victim=-1                        local
thing       camera=-1                        local
template    camera_tpl=ghost                 local
int         pcount=-1                        local
int         camera_sig=-1                    local
vector      player_dir                       local
vector      player_loc                       local

message     activated
message     pulse
message     removed

end

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

code

activated:
   player = GetSourceRef();
   player_dir = GetThingLVec(player);
   player_loc = GetThingPos(player);
   ClearActorFlags(player, 0x1);
   SetActorFlags(player, 0x840000);
   pcount = pcount + 1;
   if(pcount >= GetNumPlayers())
   {
      pcount = -1;
      call stop_cam;
      Return;
   }
   if(GetPlayerThing(pcount) == player)
   {
      call activated;
      Return;
   }
   if(camera == -1)
   {
      camera = CreateThing(camera_tpl, player);
      camera_sig = GetThingSignature(camera);
      CaptureThing(camera);
   }
   else
   {
      DetachThing(camera);
   }
   victim = GetPlayerThing(pcount);
   TeleportThing(camera, victim);
   AttachThingToThingEx(camera, victim, 0x8);
   SetCameraFocus(1, camera);
   SetPulse(0.01);
   Return;

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

pulse:
   if(IsThingCrouching(player))
   {
      call stop_cam;
      Return;
   }
   if(!(VectorDist(GetThingPos(player), player_loc) == 0))
   {
      call stop_cam;
      Return;
   }
   if(!(VectorDist(GetThingLVec(player), player_dir) == 0))
      SetThingLook(player, player_dir);
   SetCurrentCamera(1);
   Return;

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

removed:
   if(GetSenderRef() != camera) Return;
   SetCameraFocus(1, player);
   Return;

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

stop_cam:
   SetPulse(0);
   SetActorFlags(player, 0x1);
   ClearActorFlags(player, 0x840000);
   SetCameraFocus(1, player);
   if(GetThingSignature(camera) == camera_sig) DestroyThing(camera);
   camera = -1;
   CycleCamera();
   CycleCamera();
   Return;

end


QM
2004-11-29, 9:29 PM #4
Thanks very much, both of you. I didn't know how to get a vector like that, Compos, but that worked great.

I'm having another problem now, but I'll put it in a separate thread.
KOP_blujay
Just dancin'...and singin'...in the Force.

↑ Up to the top!