AttachCameraToObject
#1

I've been trying to make a smooth server entrance without the standard class selection, I decided to make an invisible object, and attach the camera to it.
pawn Код:
new JoinCamObj;
pawn Код:
public OnGameModeInit()
{
    JoinCamObj = CreateDynamicObject(19300, 2557.5522, 1496.1029, 23.7936, 0, 0, 0, 0, 0, 0, 200.0);
    return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
    SetJoinCamera(playerid);
    return 1;
}
pawn Код:
public SetJoinCamera(playerid)
{
    TogglePlayerSpectating(playerid, 1);
    AttachCameraToObject(playerid, JoinCamObj);
    return 1;
}
The code is being executed, because the player is being put into spectator mode, but the camera is not being attached to the invisible object.
Reply
#2

You need to set a delay of about 100 MS (set a timer). Wish Kye would fix this.
Reply
#3

I set a one second timer, still didn't work.
Do you do the same thing on your mode?
If so, how do you do it?

I'll try the same thing using player objects instead.

EDIT:

Strange, it worked fine if I used player objects?

Here is the code I used.
pawn Код:
new JoinCameraObject[MAX_PLAYERS];
pawn Код:
public OnPlayerConnect(playerid)
{
    SetTimerEx("OnPlayerConnectEx", 1000, false, "d", playerid);
    return 1;
}
public OnPlayerConnectEx(playerid)
{
    SetJoinCamera(playerid);
    return 1;
}
pawn Код:
public SetJoinCamera(playerid)
{
    TogglePlayerSpectating(playerid, 1);
    JoinCameraObject[playerid] = CreatePlayerObject(playerid, 19300, 1510.9978, -883.4820, 63.7863, 0.0, 0.0, 25.0);
    AttachCameraToPlayerObject(playerid, JoinCameraObject[playerid]);
    return 1;
}
Reply
#4

May I ask why you are attaching it to an object? They will be able to freely move the camera around (the lookat pos) and you won't be able to set it. Wouldn't InterpolateCameraPos/LookAt be more suited to this?
Reply
#5

I never really thought the camera functions worked in spectator mode. Didn't work with SetPlayerCameraPos. Thanks for sorting this out for me.
Reply
#6

You have to use AttachCameraToDynamicObject and not AttachCameraToObject
You have made an object with the streamer, so you have also to attach the camera with the streamer's attach function.
It's the reason why the code from your first post doesn't work.
Reply
#7

Yeah good spot, you're creating a dynamic object.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)