Converting collision vertices to world
by C Pryer · in Torque Game Builder · 01/11/2013 (12:07 pm) · 10 replies
Hi everyone
This is my first post on GG so I do apologize if this post is beating a dead horse but
I could not find anything on it.
Goal: My goal is to get my player to slide between collision boxes by adjusting his own collision
box accordingly.
So I figure I could use a trigger "that would take up the free space between the collision boxes"
and set my players collision box to the dimensions of trigger by converting both the player and the triggers collision boxes to worldPoint() but it doesn't look like getWorldPoint() works with vertices. Am I
going about this the right way or what, i'm just so lost atm.
Any help would be greatly appreciated as I am not a programmer.
Ty
This is my first post on GG so I do apologize if this post is beating a dead horse but
I could not find anything on it.
Goal: My goal is to get my player to slide between collision boxes by adjusting his own collision
box accordingly.
So I figure I could use a trigger "that would take up the free space between the collision boxes"
and set my players collision box to the dimensions of trigger by converting both the player and the triggers collision boxes to worldPoint() but it doesn't look like getWorldPoint() works with vertices. Am I
going about this the right way or what, i'm just so lost atm.
Any help would be greatly appreciated as I am not a programmer.
Ty
#2
Sry the my goal unclear..i'm just trying to get my player to slide under obstacles but the collision box on the ground and on whatever obstacles prevents my player "collision box" to be able to pass.
Does that clear it up any?
01/13/2013 (7:43 am)
Hey Lukas thx for the reply, I'll see if this works for what i'm trying to get done.Sry the my goal unclear..i'm just trying to get my player to slide under obstacles but the collision box on the ground and on whatever obstacles prevents my player "collision box" to be able to pass.
Does that clear it up any?
#3
01/13/2013 (11:18 am)
Hmm you could disable collisions on the model that the player should slide under, or disable the collision on the player while sliding under the object. I imagine the slide should be one continous movement so you dont really need to have collisions enabled
#4
Would they not? Sry I didn't say I also had gravity involved.
01/13/2013 (1:27 pm)
I was thinking that at one point but figured if I disabled the collision on the player he would fall through the ground due to gravity, and so would any mobs if they happen to be on top of the object i disable collision on. Would they not? Sry I didn't say I also had gravity involved.
#5
Had a look at the player class but it's too complicated, I don't think I have time to figure it out atm.
But I can give you the theory:
You can find where the players position is updated, and then disable collisions, move the player, enable collision again. This way the collisions is only disabled for the players move tick and the other objects wont fall through.
As for gravity, you can find where gravity is added to the velocity of the player and put a conditional statement around it. Like,
01/13/2013 (1:39 pm)
No need to apologize.Had a look at the player class but it's too complicated, I don't think I have time to figure it out atm.
But I can give you the theory:
You can find where the players position is updated, and then disable collisions, move the player, enable collision again. This way the collisions is only disabled for the players move tick and the other objects wont fall through.
As for gravity, you can find where gravity is added to the velocity of the player and put a conditional statement around it. Like,
if not sliding add gravity to velocity(Pseudo code)
#6
You wouldn't happen to know where i could find the call to disable collisions? I couldn't find it in the Doc. when I looked. I wonder if
it's something simple like object.disableCollision();
I'm not on my home pc with torque so I can't test it out yet.
01/13/2013 (1:51 pm)
Aww man that's a good idea..why didn't i think of that *smh*, that does sound like it would be able to work. You wouldn't happen to know where i could find the call to disable collisions? I couldn't find it in the Doc. when I looked. I wonder if
it's something simple like object.disableCollision();
I'm not on my home pc with torque so I can't test it out yet.
#7
You can find an example in projectile.cpp (where it disables collision with the source object) in the simulate function.
01/13/2013 (2:30 pm)
Actually it is..You can find an example in projectile.cpp (where it disables collision with the source object) in the simulate function.
// disable the source objects collision reponse for a short time while we
// determine if the projectile is capable of moving from the old position
// to the new position, otherwise we'll hit ourself
bool disableSourceObjCollision = (mSourceObject.isValid() && mCurrTick <= SourceIdTimeoutTicks);
if ( disableSourceObjCollision )
mSourceObject->disableCollision();
disableCollision();Edit: All SceneObjects have the disableCollision method.
#8
01/13/2013 (3:18 pm)
Cool, i'll give everything a shot tomorrow when I get home. Thx for everything coding is not my strong suit.
#9
function vOver::onEnter(%this, %object)
{
if(%object.getName() $= "pGuy")
{
//%newPosY = %this.getPositionY() - %object.getPositionY();
%object.disableCollision();
%object.setLinearVelocityX(10);
%object.playAnimation(Vault);
//%object.setPositionY(%object.getPositionY());
}
}
I tried it in my vOver trigger class, am I missing something? I'm using T2d not T3d. If that makes any difference, because the forums i run across seems to deal with this method in T3d i believe.
Sry, I don't know how to get my code snippets to show up like yours.
01/14/2013 (9:20 am)
I'm trying the disableCollision() method but Torsion is giving me a Unknown command errorfunction vOver::onEnter(%this, %object)
{
if(%object.getName() $= "pGuy")
{
//%newPosY = %this.getPositionY() - %object.getPositionY();
%object.disableCollision();
%object.setLinearVelocityX(10);
%object.playAnimation(Vault);
//%object.setPositionY(%object.getPositionY());
}
}
I tried it in my vOver trigger class, am I missing something? I'm using T2d not T3d. If that makes any difference, because the forums i run across seems to deal with this method in T3d i believe.
Sry, I don't know how to get my code snippets to show up like yours.
#10
01/14/2013 (10:11 am)
I'm thinking maybe the disableCollision() method you mention is now setCollisionSuppress()..
Torque Owner Lukas Joergensen
WinterLeaf Entertainment
But to convert a vertex from object coordinates to world coordinates you would get the world transform of an object obj like this:
And use the matrix to transform the vertex vert.
(Written by hand so syntax errors may occur)