PSK demo Dragon Character collision with a blank scene object.
by John Bura · in Torque X 2D · 09/09/2010 (6:47 pm) · 3 replies
Hi there,
Ive been trying to make a small switch in the PSK Demo. But I have been having no luck. Does anybody know how to make the actor collide with a blank scene object. Basically I have the rest of the code for the switch. But I need to put it in when the actor is colliding with blank scene object.
Anyway, if I can get this I feel that this would be a good small and simple tutorial for TDN. Once I get it I can put up the tutorial to make a switch in the PSK.
Thanks :)
Ive been trying to make a small switch in the PSK Demo. But I have been having no luck. Does anybody know how to make the actor collide with a blank scene object. Basically I have the rest of the code for the switch. But I need to put it in when the actor is colliding with blank scene object.
Anyway, if I can get this I feel that this would be a good small and simple tutorial for TDN. Once I get it I can put up the tutorial to make a switch in the PSK.
Thanks :)
#2
09/10/2010 (8:44 pm)
Awesome this works except there was one small thing wrong with the code. Ill keep working on this. Thank you so much Aaron :)[TorqueXmlSchemaType]
public class delegates
{
public static T2DTriggerComponentOnEnterDelegate TheOption1
{
get { return _theOption1; }
}
public static void _theOption1(T2DSceneObject ourObject, T2DSceneObject theirObject)
{
//place your code here for the action you want to take place.
//play new music, turn day to night, etc...
}
}
#3
I want to be able to add an animation which will fade in out i.e. "Level 1" and some other things such as a checkpoint marker.
Should I do this with a new GUI? Add the separate elements in there and then use the delegate to activate them? For some reason I just can't grasp this lol! Too many late nights me thinks... :-s
I'm thinking this would be a nice tutorial which I will write up.
10/12/2010 (9:14 am)
What would be the best way to draw animated sprites/Images to the screen? Kind of like a active HUD, feedback for the player.I want to be able to add an animation which will fade in out i.e. "Level 1" and some other things such as a checkpoint marker.
Should I do this with a new GUI? Add the separate elements in there and then use the delegate to activate them? For some reason I just can't grasp this lol! Too many late nights me thinks... :-s
I'm thinking this would be a nice tutorial which I will write up.
Torque 3D Owner Aaron Scovel
In this example I will use the T2DTriggerComponent.
1)The Dragon probably has an object type name, if it doesn't, then make an object type and call it something like "player" and then assign the object type to the Dragon.
2)Now add the T2DTriggerComponent to your blank scene object and set the CollidesWith to object type name of the Dragon "player".
3)You can now setup triggers with OnEnter, OnStay, and OnLeave. To use these triggers we need to setup a delegate/event to call(options to select). If you dont have a delegates component file already setup you will need to create one in C#. Project -> Add New Item. Select the T2DComponent template and give it a name like "delegates".
4)Now you need to setup the delegate, if this is a fresh file just replace everything inside your namespace with this. assuming you named the file delegates
public class delegates { [TorqueXmlSchemaType] public static T2DTriggerComponentOnEnterDelegate TheOption1 { get { return _theOption1; } } public static void _theOption1(T2DSceneObject ourObject, T2DSceneObject theirObject) { //place your code here for the action you want to take place. //play new music, turn day to night, etc... } }5)Save/Build. Now go back to the Torque X editor and on the T2DTriggerComponent you will be able to select TheOption1 from the OnEnter.
Extra Note: If you want it to be a one time switch, you will want to either disable it after the code is ran, or setup an OnLeave to disable the Trigger. You can make tons of different options in your delegate file to use throughout your game.
Edit:
Needs to be relocated above the class (look at johns correction below).