New platformer tutorial on TDN
by Phillip O'Shea · in Torque Game Builder · 07/28/2007 (3:36 pm) · 31 replies
tdn.garagegames.com/wiki/TGB/CustomPlatformer
Hi Guys,
Above is the link to a new platforme tutorial I have been working on over the last week or so. Check it out, and give some feedback.
I'll write up more of a description later.
Phil
Hi Guys,
Above is the link to a new platforme tutorial I have been working on over the last week or so. Check it out, and give some feedback.
I'll write up more of a description later.
Phil
About the author
Head of Violent Tulip, a small independent software development company working in Wollongong, Australia. Go to http://www.violent-tulip.com/ to see our latest offerings.
#2
Could you explain you opinion about "castCollision and alike"? In your tutorial you wrote:
What did you mean? Is it a bad style to use these functions?
I'm sorry for the noob question. I have no sufficent experience in TGB.
07/30/2007 (6:10 am)
Thank you for good tutorial Phil,Could you explain you opinion about "castCollision and alike"? In your tutorial you wrote:
Quote:
I speak of "castCollision" and alike. While these kinds of functions may work some of the time, they are (usually) implemented poorly and often give undesirable results.
What did you mean? Is it a bad style to use these functions?
I'm sorry for the noob question. I have no sufficent experience in TGB.
#3
@Dmitriv:
castCollision can be a very useful and efficient function... what I think Phillip was meaning is that though it was a quick and semi-effective solution in some previous implementations, for this specific use in a platformer there are better ways.
07/30/2007 (9:19 am)
Good tutorial, thanks for posting it.@Dmitriv:
castCollision can be a very useful and efficient function... what I think Phillip was meaning is that though it was a quick and semi-effective solution in some previous implementations, for this specific use in a platformer there are better ways.
#4
@Dmitriv,
Matthew hit the nail on the head. CastCollision can be useful some situations, but in the MiniPlatformerTutorial, (while it is a great place to start) uses it as an easy way out. It is also implemented rather poorly (in my opinion). One example is where it applies temporary physics then casts a collision to see if there will be a collision soon, then reverts back to the old physics. This isn't really an effective sollution.
I have been writing the code for ramps and sloped surfaces, I am having a little trouble, but I will hopefully have something up there soon.
07/30/2007 (2:23 pm)
Thank you guys,@Dmitriv,
Matthew hit the nail on the head. CastCollision can be useful some situations, but in the MiniPlatformerTutorial, (while it is a great place to start) uses it as an easy way out. It is also implemented rather poorly (in my opinion). One example is where it applies temporary physics then casts a collision to see if there will be a collision soon, then reverts back to the old physics. This isn't really an effective sollution.
I have been writing the code for ramps and sloped surfaces, I am having a little trouble, but I will hopefully have something up there soon.
#5
I use CastCollision(0) in my code and it work fine for me. Is it better to use t2dScenegraph::pickRadius(...), or t2dScenegraph::pickRect(...) instead CastCollision(0) (I use simple collision bounds: circles and rectangles)?
Sorry for possible offtop!
07/31/2007 (12:01 am)
Matthew, Phillip, thank you for your explanation.I use CastCollision(0) in my code and it work fine for me. Is it better to use t2dScenegraph::pickRadius(...), or t2dScenegraph::pickRect(...) instead CastCollision(0) (I use simple collision bounds: circles and rectangles)?
Sorry for possible offtop!
#6
However, I feel that the pick method works a lot better and there is a lot of flexibility with it.
But, thats just my 2c
07/31/2007 (12:19 am)
I'm not expert, but I would say that it really depends on your situation. If you are happy with the way it is working, and you know it *will* work when you need it to, not just some of the time, then I'd say its fine.However, I feel that the pick method works a lot better and there is a lot of flexibility with it.
But, thats just my 2c
#7
I've tryed several pick metods and it work fine for me too. I suppose that pickRadius(), pickRect(), etc. is more simple and more preferable in my case than CastCollision() or CastCollisionList().
07/31/2007 (9:58 pm)
Thank you for your opinion, Phill.I've tryed several pick metods and it work fine for me too. I suppose that pickRadius(), pickRect(), etc. is more simple and more preferable in my case than CastCollision() or CastCollisionList().
#8
I tend to get annoyed when other people ask such questions, but here goes. In your tutorial you said, "I have worked on Moving Platforms and Ramps/Slopes and will release tutorials on these in the near future."
Can you give us any guess when that would be?
In my game, the world (and ground) slowly rocks back and forth like a boat. When it's tilting down, the player sort of hops, as the ground is consistently being dropped from his feet. I'm guessing that's similar to the moving platforms issue. Very stumped myself.... :)
08/20/2007 (6:16 pm)
Phillip,I tend to get annoyed when other people ask such questions, but here goes. In your tutorial you said, "I have worked on Moving Platforms and Ramps/Slopes and will release tutorials on these in the near future."
Can you give us any guess when that would be?
In my game, the world (and ground) slowly rocks back and forth like a boat. When it's tilting down, the player sort of hops, as the ground is consistently being dropped from his feet. I'm guessing that's similar to the moving platforms issue. Very stumped myself.... :)
#9
I can put it up this evening (I live in Australia, so its going to be late). I have had 90% of the tutorial written, I just haven't put it on the site.
It isn't 100% working, I hope that people can see any issues I have and fix them.
Basically what I've done for Moving Platforms is in the updateOnGround function I've just set the player's movement to that of the object he is sitting on top of, its pretty basic.
But for slopes, its a tad more complicated and I will explain the details of what I've got.
When the ground is picked, it finds the two collision poly points that the pick line intersects, or is between in the case of parallelism. It will then calculate the normal vector and that vector is used when the player moves.
If you have check out my tutorial, I have disabled constant velocity (or gravity) unless the player is in the air. This means that when he is on sloped ground, he will not try to move downwards. So, am I correct in that you have constant force being applied to your player at all times?
Now that I have the normal vector established, I apply it to the movement vector when I move around. I can't remember exactly what I did off the top of my head, but it is something like:
It is something like the above, but you must account for the direction the player is facing when on the slope. Sounds confusing? It is kinda.
I will make sure that I update the tutorial tonight. Hope this makes a little bit of sense.
08/20/2007 (6:44 pm)
Peter,I can put it up this evening (I live in Australia, so its going to be late). I have had 90% of the tutorial written, I just haven't put it on the site.
It isn't 100% working, I hope that people can see any issues I have and fix them.
Basically what I've done for Moving Platforms is in the updateOnGround function I've just set the player's movement to that of the object he is sitting on top of, its pretty basic.
But for slopes, its a tad more complicated and I will explain the details of what I've got.
When the ground is picked, it finds the two collision poly points that the pick line intersects, or is between in the case of parallelism. It will then calculate the normal vector and that vector is used when the player moves.
If you have check out my tutorial, I have disabled constant velocity (or gravity) unless the player is in the air. This means that when he is on sloped ground, he will not try to move downwards. So, am I correct in that you have constant force being applied to your player at all times?
Now that I have the normal vector established, I apply it to the movement vector when I move around. I can't remember exactly what I did off the top of my head, but it is something like:
%actor.setLinearVelocity(%moveSpeed*getWord(%normal, 1), %moveSpeed*getWord(%normal, 0));
It is something like the above, but you must account for the direction the player is facing when on the slope. Sounds confusing? It is kinda.
I will make sure that I update the tutorial tonight. Hope this makes a little bit of sense.
#10
You are very prompt, by the way. I'm lucky you're on top of this.
08/20/2007 (6:54 pm)
Makes sense on first read. Still moving my code from the old tutorial to your current one, so I don't have anything useful to add.You are very prompt, by the way. I'm lucky you're on top of this.
#11
Its not working 100% but it is the outline of what needs to be done. When I work out many of the kinks I know of, I will modify what I've put up there.
Let me know what you all think.
08/21/2007 (4:05 am)
I've updated it quickly to give you an idea of what I've been doing.Its not working 100% but it is the outline of what needs to be done. When I work out many of the kinks I know of, I will modify what I've put up there.
Let me know what you all think.
#12
Maybe this was my fault, but in the function 'getCollisionInfo':
08/21/2007 (11:36 am)
It is showing some promise, but on my long, steady slope it does jerk around a bit. I'm not able to draw collision points like you say because my slope is a rectangle turned on it's side. Maybe that's why.Maybe this was my fault, but in the function 'getCollisionInfo':
%this.owner.collisionPoint_Y = getWord(%minBottom, 1) + %testPoint_a*%diffBottom_Y - 0.5;would give me a syntax error until I rewrote it again myself. Might have something to do with the line above is too wide to fit. Even after I made that one line, the line mentioned above gave me trouble until I re-wrote it.
#13
Yeah, some of the lines are too long to fit on the page so I spaced them out, maybe I should rework those. Sorry about that.
08/21/2007 (2:25 pm)
Could you post a screenshot or something? And give a detailed explanation of the problem?Yeah, some of the lines are too long to fit on the page so I spaced them out, maybe I should rework those. Sorry about that.
#14
09/25/2007 (7:50 pm)
I just found this searching around the forums. This is a great resource!! Thanks for taking the time to do it.
#15
I've completely reworked the way that I have handled everything. It is much, much less buggy than before, but I still need to refine it.
However, thank you for the support!
09/25/2007 (7:53 pm)
Charles, there should hopefully be an update popping up very soon.I've completely reworked the way that I have handled everything. It is much, much less buggy than before, but I still need to refine it.
However, thank you for the support!
#16
I have learned the hard way to always compile and run the source for a tutorial prior to going through it since if it doesn't compile and run cleanly there really isn't any point in learning from something thats broken.
09/26/2007 (12:25 pm)
I don't see a link in the tutorial to download the source.I have learned the hard way to always compile and run the source for a tutorial prior to going through it since if it doesn't compile and run cleanly there really isn't any point in learning from something thats broken.
#17
tdn.garagegames.com/wiki/TGB/AdvancedPlatformer
09/28/2007 (9:07 am)
Was this resource made for TGB 1.5.1 or 1.1.3? Cant seem to get it to work with 1.5.1.tdn.garagegames.com/wiki/TGB/AdvancedPlatformer
#18
09/28/2007 (2:01 pm)
AdvancedPlatformer was 1.1.3 or earlier.
#19
Thanks so much for your time! It is really very appreciated.
--clint
10/26/2007 (6:27 am)
This resource looks really good -- I'm a very frustrated user of the MiniPlatformerTutorial, and I'm looking forward to what this resource might be able to do to fix some of those issues. I don't need ramps -- I just want a platformer where I'm not climbing walls. Do the current issues with the tutorial resolve those issues? Can you please give me a few hints as to the nature of issues that are in the CustomPlatformer tutorial?Thanks so much for your time! It is really very appreciated.
--clint
#20
10/27/2007 (3:16 pm)
I am SO FRUSTRATED!!!! TBG docs are so PISS POOR.... and outdated!!!!!! And Torque-X got the platformer starter kit!!!!! I wish they would stop comming out with Torque A ,B, C,D, D+....... and just make *BETTER* * UPDATED* DOCS!!!!!! I'm losing my mind..................
Torque Owner Matt Van Gorkom