About tutorial - Asteroids
by Shek Siu Hang · in Torque Game Builder · 12/13/2009 (11:40 am) · 3 replies
I,m following the tutorial of Asteroids(http://tdn.garagegames.com/wiki/TGB/Tutorials/Asteroids)
I,m new of the TGB. I hope someone can answer my question.
When I set the playership's Graph Group as 0 and the projectile as 1
If I press the space key(Shooting),How Come the projectile can damage the player Ship itself?
If I set playership's Graph Group equal or higher than 1, the problem will not occur.
Why?
Second Question,what is the Difference between Collision Group and Graph Group(Scene Object). As a menioned above, whatever I set playership and projectile in difference collision group, the ship still destoryed by its own projectile.
Thank you!
I,m new of the TGB. I hope someone can answer my question.
When I set the playership's Graph Group as 0 and the projectile as 1
If I press the space key(Shooting),How Come the projectile can damage the player Ship itself?
If I set playership's Graph Group equal or higher than 1, the problem will not occur.
Why?
Second Question,what is the Difference between Collision Group and Graph Group(Scene Object). As a menioned above, whatever I set playership and projectile in difference collision group, the ship still destoryed by its own projectile.
Thank you!
#3
I do have a couple of follow-up questions if anyone has a quick answer.
* do groups save time during collision detection? for instance, maybe objects in the same group go into a list, and when collision checks are done, it only checks with appropriate lists, not checking against objects that aren't in the appropriate groups.
* why does collision checking allow layer masks as well? this is where my confusion came from. it seems I can limit collision checks to group OR layers or both!
05/21/2011 (1:53 pm)
This post explains groups to me splendidly! Thanks!I do have a couple of follow-up questions if anyone has a quick answer.
* do groups save time during collision detection? for instance, maybe objects in the same group go into a list, and when collision checks are done, it only checks with appropriate lists, not checking against objects that aren't in the appropriate groups.
* why does collision checking allow layer masks as well? this is where my confusion came from. it seems I can limit collision checks to group OR layers or both!
Associate Mike Lilligreen
Retired T2Der
If I set my playership to group 1 and on the collision tab I specify that the playership is only allowed to collide with objects from group 0: the graph group of the playership is 1 and the collision group is 0, which you can check through the functions playership.getGraphGroup() and playership.getCollisionGroups(). This means the playership will only register a collision with group 0, if it collides with an object from group 1 or above, nothing will happen.
In the tutorial we are attaching specific behaviors to the playership, the projectile, and the asteroids. We allow the ship to take damage, the projectile to deal damage, and the asteroids to take and deal damage. The goal is to have the projectiles deal damage to the asteroids and the asteroids deal damage to the playership. To avoid something unwanted like the projectile dealing damage to the playership, we set up a specific group for the ship and projectile (group 1) and a specific group for the asteroids (group 0). Again, this is the graph group.
On the collision tab, we specify in the collsion group section that the asteroids are only allowed to collide with group 1 and the ship and projectile are only allowed to collide with group 0. This prevents asteroids from registering a collision with other asteroids (group 0 colliding with group 0) and prevents the projectile from registering a collision with the playership (group 1 colliding with group 1).