Game Development Community

XnaChopperStrike Question (Kanalakis Textbook Version) (RESOLVED)

by Pat Frank · in Torque X 2D · 09/10/2009 (4:14 am) · 4 replies

I've been building the chopper strike described in Chapter 9, and I can't get the projectile to collide with the enemy. The projectile just passes through the enemy chopper without doing anything. I tried creating an Object Type of objEnemy and assigning it to the enemy chopper in the Scripting section, and then setting the enemy chopper's ResolveCollision property to KillCollision, but nothing changed.

I'd appreciate any suggestions on this. Thanks!

#1
09/10/2009 (4:19 am)
Oh, I haven't been able to implement inventory/item pickup either. Any suggestions there would also be appreciated. :-)
#2
09/10/2009 (12:01 pm)
Ah I can actually answer this one...

In order for two objects to collide they must both have each other's Object Type set in the CollidesWith field of the Collision Component.

Steps:

1)Create two Objects Types (You already have one, ObjEnemy).

2)Make sure both of the objects you want to collide are assigned their Object Type under the scripting tab for that object(i.e. Your enemy helicopter should have its Object Type set to ObjEnemy)

3)Set the CollidesWith for both objects in the Collision Component (i.e. Your player CollidesWith should be set to ObjEnemy and your enemy CollidesWith should be set to the object type given to the player)

4) Set the Resolve Collision to whatever is applicable for that object. (i.e. Your enemy could be GarageGames.Torque.T2D.T2DPhysicsComponent.KillCollision and your player could be .BounceCollision or even None I believe)

#3
09/10/2009 (2:52 pm)
I appreciate the feedback. Going over all that I discovered that the weapon component on the player object needs to be set to the enemy object type, which is not in the instructions (though it's shown in the picture on page 186). There's actually quite a lot missing from the instructions, but I think the intent was for the student to build on previous experience (like where it says you should have the camera follow the player per the previous chapter). This is a good thing (I like this book a lot, and all of my favorite textbooks have a few minor issues, so I'm not complaining!).

But I wouldn't have found this if not for your reply so I really appreciate it, Randy. The devil is always in the details! :-)

(How do I mark a thread "resolved"?)
#4
09/10/2009 (4:20 pm)
I'm glad you solved your problem.

Don't feel alone when you run into issues with the book. I actually attempted to break down an entrie chapter in one of my threads because I kept running into issue after issue.

I'm the type of person who by default goes into a book expecting it to have every detail and to be close to flawless. But with this book I realized John writes with less details than you may expect (like when he leaves out where to put the code in a particular class) but if you actually use basic logic you can usually figure out what he is getting at. In the end I feel you actually learn more... if you stick with it that is.

It is also important to know that there are some prominent errors throughout the book (per John's explanation in a previous thread about an error in chapter 15 when doing audio). Once I got out of the mindset of thinking there was no way the book was wrong and I must be making an error, I was able to solve my problems... like you did.

I usually just edit the title to resolve these things.