How can I implement the pseudo-3d collision detection like Castle Crashers in TGB?
by JackeyYu · in Torque Game Builder · 10/23/2009 (6:45 am) · 9 replies
I have several questions in implementing this type of collision detection.
I want my player to move left and right ( x-axis), up and down (z -axis) , and junp (y-axis).
But in TGB, I can only find the 2d collision. If I move into depth (z-axis),
what should I do to cast collision with the 2d-ground ?
Is there any tutorial about this title?
I need some helps, Thanks a lot!
I want my player to move left and right ( x-axis), up and down (z -axis) , and junp (y-axis).
But in TGB, I can only find the 2d collision. If I move into depth (z-axis),
what should I do to cast collision with the 2d-ground ?
Is there any tutorial about this title?
I need some helps, Thanks a lot!
About the author
#2
I still have some problems. For example, Whan I get down from a highland, how can I know that my player touch the ground?
10/25/2009 (1:25 am)
Thanks a lot!I still have some problems. For example, Whan I get down from a highland, how can I know that my player touch the ground?
#3
10/25/2009 (4:05 am)
By highland do you mean a raised platform? Or just from when you jump?
#4
My question is that, when I jump onto a box, how can I know if my bottom touch the box's top.
In 2D platform, the TGB's collision can perfectly do it. But I want my player to walk into depth, I don't know how to do the same thing such as jump onto a box and jump down.
Thanks again!
10/25/2009 (10:48 pm)
Such as a box.My question is that, when I jump onto a box, how can I know if my bottom touch the box's top.
In 2D platform, the TGB's collision can perfectly do it. But I want my player to walk into depth, I don't know how to do the same thing such as jump onto a box and jump down.
Thanks again!
#5
Imagine that your characters is moving on its own X-Y plane. Those coordinates will then map to screen X-Y coordinates. It might even be as simple as X(screen) = X(world) and Y(screen) = 0.5 * Y(world).
Really, your Y(screen) will probably equal something like 0.5 * Y(world) + Z(world).
As you place boxes in your editor, you can reverse these formulas to put the box into world coordinates.
I would then assign a set of 3D box coordinates to the players and objects in the world. For example, a box might be defined as the box (0,0,0) to (1,1,1) and a player might be as the box (0,0,0) to (1,1,2).
At this point, though, you'll have to do your own physics. Box-box collisions are really fast to do though. There are a lot of optimizations you can make, too. Finally, you could also get a lot of speed by using the Pro license and writing some of it in C++.
I hope that all makes sense. If not, just let me know and I'll try to clarify some of it more.
10/25/2009 (11:13 pm)
Well... once again I know how I'd do it, but I'm not certain if there is a better way.Imagine that your characters is moving on its own X-Y plane. Those coordinates will then map to screen X-Y coordinates. It might even be as simple as X(screen) = X(world) and Y(screen) = 0.5 * Y(world).
Really, your Y(screen) will probably equal something like 0.5 * Y(world) + Z(world).
As you place boxes in your editor, you can reverse these formulas to put the box into world coordinates.
I would then assign a set of 3D box coordinates to the players and objects in the world. For example, a box might be defined as the box (0,0,0) to (1,1,1) and a player might be as the box (0,0,0) to (1,1,2).
At this point, though, you'll have to do your own physics. Box-box collisions are really fast to do though. There are a lot of optimizations you can make, too. Finally, you could also get a lot of speed by using the Pro license and writing some of it in C++.
I hope that all makes sense. If not, just let me know and I'll try to clarify some of it more.
#6
Now I know how to do my own physics.
I also have some ideas about it. Every time before casting collisions, I transfer my object to the layer of 2d-ground, and after casting collisions, then transfer the object back to its own layer? Does it works in TGB?
Finally, Thanks again!
10/26/2009 (12:18 am)
Thanks for the quick reply. And I think I got your point.Now I know how to do my own physics.
I also have some ideas about it. Every time before casting collisions, I transfer my object to the layer of 2d-ground, and after casting collisions, then transfer the object back to its own layer? Does it works in TGB?
Finally, Thanks again!
#7
I think you could use the built-in collision system as a first test. If those are colliding, then you could test their pre-defined boxes.
10/26/2009 (4:26 am)
I'm not positive that I know what you mean.I think you could use the built-in collision system as a first test. If those are colliding, then you could test their pre-defined boxes.
#8
11/04/2009 (4:55 am)
Should I buy the AdventureKit for Making game like Castle Crashers?
#9
11/06/2009 (3:59 pm)
it not necessary to buy the adventure kit but the kit does have alot of interesting source code and art assets. Everything you need is pretty much in the tdn. I was able to create a quick castle crashers prototype in a week. I got movement, jumping, fighting, crude combos, and random drops in about a week. I found most of my answers on the forums. I didn't do pick-ups or an inventory system but these things have been done. You basically have everything you need just tackle one task at a time.
Associate William Lee Sims
Machine Code Games
First, I wouldn't do collision with the ground. Just have a valid area that characters can move in and have a border that they collide with.
To do your up and down, you'll use the Y-axis. To handle jumping, you'll have to write some scripts to handle it (but still move in the Y-axis).
If I were writing this, I'd probably just have custom collision code. When objects collided, I'd check they X-Y coordinates combined with the jump-height to see if the collision really happened.
If you need some clarification or more specific help, just let me know!