Game Development Community

"Collision" without collision

by Adam McDonald · in Torque Game Builder · 01/14/2012 (6:40 am) · 11 replies

Is there a way to have a "collision" occur by having an object completely pass through another object? Or something that will have an equivalent effect?

Right now I have my player object change colours when it touches an object in the world, which is what I want, but if I try to eliminate any other effects it has on the character (i.e. preventing it from moving forward unhindered) the colour changing effect goes away.

I am very open to using things that aren't collision to get the same effect, but so far it seems to have come the closest to doing what I want of the things I've tried. Any help or advice would be greatly appreciated. I don't have a ton of programming knowledge (but I do have a little bit) so I'm mostly getting by on trial and error mixed with tutorials.

#1
01/14/2012 (7:31 am)
You can either code it by the proximity of the objects coming together and not even worry about collision or you can use the castcollision() method and set the value to 0 to determine when the objects are going to collide and then have the objects turn color.
#2
01/14/2012 (10:48 am)
Quote:but if I try to eliminate any other effects it has on the character (i.e. preventing it from moving forward unhindered)

I'm a little unsure of all the other effects you're experience, but it sounds like you may at least have the physics engine causing things to stop. If so, you can turn that off. Try this:

* Go to your scene objects in the scene editor (the main T2D tool) and select them one at a time.
* Go to their "Collision" section in the right panel. Make sure to uncheck "Send Physics" and "Receive Physics."
* I think I can assume you have "Callback" checked already since you are finding a way to change colors.
* Finally, you *may* need to set the "Collision Response" correctly, even though you've turned physics off. I think I remember having a problem before. Try "Clamp".

See if that helps!
#3
01/14/2012 (12:27 pm)
I did turn physics off, finding that the objects still collide when I do that. I didn't mess with Collision Response much though, so I'll give that a shot. If that doesn't work I'll try the castcollision() method that Glenn mentioned.

Would using triggers be viable in this situation? I recall trying it and stopping for some reason or another, but from my experience with other game engines (mostly Unreal) triggers are what I would have used in this situation.

Thanks!

#4
01/14/2012 (1:20 pm)
I use onCollision without physics all the time. The only effect is that it calls my onCollision routine and lets me do whatever I want. You have to make sure both objects have their physics off. And I do recall something odd happening based on collision response even with physics off.
#5
01/14/2012 (11:02 pm)
Explain exactly what you want to achieve I'll runn a quick experiment to see if I have the same problem
#6
01/15/2012 (12:40 am)
Glenn:

I am working on a sidescroller, with my main code based on the platformer tutorial. I have a "character" (currently a square) that will change to different colours and interact with the environment in different ways based on colour. I want the colour change to occur when the character touches "gates" (also currently squares), but I want the character to pass through/overlap them completely unhindered by any sort of physics or collision. The colour change occurs by triggering a function that sets a colour variable to a value from 0-6, and depending on the value the sprite changes. I did it this way because there would be other things that refer to the "colour" variable. For example, I also want most of the environment to switch to different sprites depending on the value of the colour variable (not to different colours, but with slight differences to indicate how you are able to interact with the object... i.e. something that you can pass through gets faded, something that becomes solid becomes a solid colour with a border, etc.).

I still haven't tried anything suggested in this thread, so the solution could be something already suggested. I didn't expect to get so many helpful responses so quickly!
#7
01/16/2012 (2:32 am)
Well I would use triggers in that case so that when the trigger is activated you can set multiple objects to change color. Just leave the gates basic static sprites and place a trigger directly on top of them.
#8
01/16/2012 (8:06 am)
Well I would use triggers in that case so that when the trigger is activated you can set multiple objects to change color. Just leave the gates as basic static sprites and place a trigger directly on top of them.
#9
01/17/2012 (10:58 pm)
Alright, taking a shot at triggers. I have no clue what I'm doing. Does anyone have any good links to tutorials on triggers or any tips on getting started? Currently I have a trigger that has this script:

function redGate::onEnter(%this, %object)
{
		%object.red();
}

"redGate" is the Trigger's class, "red()" is a function that sets the colour to red. I know the function works because I have a button mapped to that function for debugging/testing, plus it worked with collision before. As far as I can tell I assigned the class to the trigger properly in the editor and the script should be executing properly. Any ideas?
#10
01/18/2012 (4:48 am)
Yeah that is pretty much it. Did you identify the sceneobject's class in the scripting tab? Edited my previous statement
#11
01/19/2012 (12:28 am)
Yeah, I did. By that you mean entering "redGate" in the "Class" field for the trigger, right?