Change Camera on EnterTrigger
by Michael S · in Torque 3D Beginner · 04/30/2013 (10:04 am) · 17 replies
Basically, I want to make it so when my player walks into this trigger, his view will go to another camera and his controls will be disabled.. I am using afx 2 with UAISK. Frankly, this shouldn't matter.... I tried following the adventure camera tutorial because it gives an example of what I want, and basically sets it up for me, problem is, it doesn't work. I think that once the camera switches everything will be fine when it comes to controls, so I just need it to switch. Anyone know what to do?
http://gyazo.com/d8c0097943bea2ac4a4281a20738a936.png?1367341236
That is what happens in debugging, whether I set it up in the triggers commands or via script. Yes I executed the script when I did it via script.
http://gyazo.com/d8c0097943bea2ac4a4281a20738a936.png?1367341236
That is what happens in debugging, whether I set it up in the triggers commands or via script. Yes I executed the script when I did it via script.
About the author
#2
Example please? By the way, I actually did remove the trigger tick from the datablock, but nothing happens still, plus nothing in the debugging..
04/30/2013 (1:22 pm)
I don't think so actually, as I was following this tutorial. http://docs.garagegames.com/torque-3d/official/content/documentation/Scripting/Advanced/AdvPrototype.htmlExample please? By the way, I actually did remove the trigger tick from the datablock, but nothing happens still, plus nothing in the debugging..
#3
04/30/2013 (3:34 pm)
I'd recommend creating a new trigger datablock. Then define functions ::onEnterTrigger and ::onExitTrigger specifically for the new datablock. I've had similar issues with the standard trigger in the past.
#4
Specifically, check the sections on Camera Setup and Mouse Setup - you will need to pay attention to the code that goes into game/scripts/server/gameCore.cs. In function GameCore::preparePlayer(%game, %client). I'll try to find what the heck was going on with the control object when I get home - it looks like I missed a part in the tutorial. You can download the scripts for that tutorial and check GameCore::preparePlayer() and GameCore::spawnPlayer().
04/30/2013 (5:17 pm)
Note at the beginning of the Adventure Prototype that it recommends you complete the RTS Prototype, where the majority of the camera setup is done....Specifically, check the sections on Camera Setup and Mouse Setup - you will need to pay attention to the code that goes into game/scripts/server/gameCore.cs. In function GameCore::preparePlayer(%game, %client). I'll try to find what the heck was going on with the control object when I get home - it looks like I missed a part in the tutorial. You can download the scripts for that tutorial and check GameCore::preparePlayer() and GameCore::spawnPlayer().
#5
04/30/2013 (6:04 pm)
I will look through the rts tutorial again, and if all fails, I will simply do what Robert recommended. I will report back here soon!
#6
04/30/2013 (6:45 pm)
Ah, and in the Adventure Prototype you should have created a new trigger datablock, so if you did not that might be part of the problem.
#7
Which brings me to another thought / idea... Might I just spawn the player as this camera, I was really just spawning the player into the trigger so I could get it set up easier, but its not working, and it might just be easier to spawn the player as this camera? I must say, the camera stuff in Torque 3d is not my area of expertise..
04/30/2013 (6:52 pm)
I did create one actually. If only that were the problem! Also, I went through those functions you mentioned in specific and added what was different, I had both scripts open side to side. So, any more ideas? By the way, if we can fix this, I can post a resource on making a mission load in the main menu, as that's basically what i'm doing, I have everything but the camera working..Which brings me to another thought / idea... Might I just spawn the player as this camera, I was really just spawning the player into the trigger so I could get it set up easier, but its not working, and it might just be easier to spawn the player as this camera? I must say, the camera stuff in Torque 3d is not my area of expertise..
#8
http://gyazo.com/86b2cf1e952025bb7dda38e04632d768.png
I am using %connection.setControlObject();
Problem is, I don't know what to put in the ()
I have tried a few things, such as making this: http://gyazo.com/2b4a8cd4d2bb27e39ffa706a76268d6e.png
Into this: http://gyazo.com/5e9f03f113a05c9aaec11afacc0cdee1.png
and then using %LoginCam in the ()s
What happens when I do that is on loading it says waiting for server, and stops there.. I tried taking out the %connection in the beginning, didn't work. I also just tried using plain old LoginCam. Plus, I did Camera(LoginCam)
Nothing has worked so far, and I bet its something simple I need to put in. Any ideas?
05/01/2013 (7:00 am)
Okay, so I looked into a few things, and I think I can get this to work, as long as I can figure this last thing out..http://gyazo.com/86b2cf1e952025bb7dda38e04632d768.png
I am using %connection.setControlObject();
Problem is, I don't know what to put in the ()
I have tried a few things, such as making this: http://gyazo.com/2b4a8cd4d2bb27e39ffa706a76268d6e.png
Into this: http://gyazo.com/5e9f03f113a05c9aaec11afacc0cdee1.png
and then using %LoginCam in the ()s
What happens when I do that is on loading it says waiting for server, and stops there.. I tried taking out the %connection in the beginning, didn't work. I also just tried using plain old LoginCam. Plus, I did Camera(LoginCam)
Nothing has worked so far, and I bet its something simple I need to put in. Any ideas?
#10
Here is a solution that "works" but it has its own problems....
05/02/2013 (8:41 pm)
Don't spawn in the trigger - it doesn't trip the onTriggerEnter().Here is a solution that "works" but it has its own problems....
function CameraTriggerData::onEnterTrigger(%this, %trigger, %obj)
{
echo(" @@@ object: " @ %obj @ " entered trigger " @ %trigger.name);
%client = %obj.client;
switch$(%trigger.name)
{
case "cameraTrigger1":
LocalClientConnection.setFirstPerson(false);
%camera = LocalClientConnection.camera;
%client.setControlObject(%camera);
echo(" @@@ - camera : " @ %camera );
//serverCmdoverheadCam(%client);
%camera.controlMode = "Stationary";
%camera.position = cameraPoint1.position;
%camera.rotation = cameraPoint1.rotation;
showCursor();
//%client.setControlObject(%obj);
}
}
function CameraTriggerData::onLeaveTrigger(%this, %trigger, %obj)
{
echo(" @@@ object: " @ %obj @ " left trigger " @ %trigger.name);
LocalClientConnection.setControlObject(%obj);
LocalClientConnection.setFirstPerson(true);
hideCursor();
}It disconnects the camera from the player and sets its position, but control is disconnected from the player. This requires some more work to be really useful - or you could switch to "click-to-move" when in this mode....
#11
http://gyazo.com/42595683878d56852d4565ae96dea445.png
In Init.cs I made it so that it loads said level when the game starts, instead of instantly opening the main menu. So basically, when I click play, it loads this level right away. Problem is, I want this to be in the bg of my main menu, so I don't want to have control over the player, and I want the camera to be off the ground. So I need this to make that happen. This is why I said I could make a tutorial if we can solve this.
I changed around what you gave me so it matches my work. However, that waiting for server issue has resurfaced.
This is what I turned it into: http://gyazo.com/384c3bfb153360ac1a7273563be45fc3.png
This is my trigger and camera: http://gyazo.com/384c3bfb153360ac1a7273563be45fc3.png
05/03/2013 (6:07 am)
That's whats so great about what I am trying to do Richard, I don't want control! Let me explain what I am doing, I am trying to set up a stationary camera to look over a level right when the level loads, this is my mainmenu level. http://gyazo.com/42595683878d56852d4565ae96dea445.png
In Init.cs I made it so that it loads said level when the game starts, instead of instantly opening the main menu. So basically, when I click play, it loads this level right away. Problem is, I want this to be in the bg of my main menu, so I don't want to have control over the player, and I want the camera to be off the ground. So I need this to make that happen. This is why I said I could make a tutorial if we can solve this.
I changed around what you gave me so it matches my work. However, that waiting for server issue has resurfaced.
This is what I turned it into: http://gyazo.com/384c3bfb153360ac1a7273563be45fc3.png
This is my trigger and camera: http://gyazo.com/384c3bfb153360ac1a7273563be45fc3.png
#12
05/03/2013 (6:57 am)
If you're looking to have this happen immediately, then fire that in your scripts\server\gameCore.cs GameCore::onMissionLoaded() function - just be sure to set up some sort of flag so you only do this at the menu in your menu GUI's onWake() (and unflag in your menu GUI's onDialogPop() or onSleep()).
#13
Starting to get quite frustrated now lol, this waiting for server thing just won't quit. Thank you so much for all the help so far, truly appreciate it, I will certainly be willing to give you some money for helping me out when / if we get this working!
05/03/2013 (9:14 am)
I got rid of everything that I added to get the camera to work, and found that this http://gyazo.com/3b93eb34884b41a205fde3b64bdd1fa2 is causing problems now... Starting to get quite frustrated now lol, this waiting for server thing just won't quit. Thank you so much for all the help so far, truly appreciate it, I will certainly be willing to give you some money for helping me out when / if we get this working!
#14
And hopefully this thread will be helpful to someone else, too....
05/03/2013 (9:35 am)
Don't worry about it - if a question falls into the "easy fix" or "interesting" categories for me I'll lend a hand, and this one is interesting. Camera control is a little odd in Torque but you can do a lot with it; the issue is coming to grips with how the system works.And hopefully this thread will be helpful to someone else, too....
#15
The Torque 3D Game Development Cookbook has a section for making levels as your main menu along with a host of other great tutorials and helpful information about working with T3D. Here's a link to pickup a PDF version:
http://www.packtpub.com/torque-3d-game-development-cookbook/book
Really highly recommended.
If you're looking to load an Observe mode with every level with a GUI then check out this thread, it has a couple resources that you could modify to suit your needs:
http://www.garagegames.com/community/forums/viewthread/132096
05/03/2013 (10:21 pm)
Quote:Let me explain what I am doing, I am trying to set up a stationary camera to look over a level right when the level loads, this is my mainmenu level.
The Torque 3D Game Development Cookbook has a section for making levels as your main menu along with a host of other great tutorials and helpful information about working with T3D. Here's a link to pickup a PDF version:
http://www.packtpub.com/torque-3d-game-development-cookbook/book
Really highly recommended.
If you're looking to load an Observe mode with every level with a GUI then check out this thread, it has a couple resources that you could modify to suit your needs:
http://www.garagegames.com/community/forums/viewthread/132096
#16
05/04/2013 (8:41 am)
I will be picking that book up soon, thanks!
#17
05/04/2013 (10:02 pm)
Yeah, you know, I forgot about Observer Cameras....
Torque Owner Richard Ranft
Roostertail Games