Game Development Community

Finding out if you've hit the wall or the roof

by Vishal Bhanderi · in Torque X Platformer Kit · 08/24/2007 (11:50 am) · 2 replies

Hey guys,

Just want to find out how I can tell if i've hit the roof or the walls. I've tried using:

public virtual void ResolveActorCollision()

// if object was not a ground surface...
if (!groundSurface)
{
}

But It doesn't know whether it's a wall or not. Any methods I might of missed ?

#1
10/01/2008 (6:56 pm)
It's over a year later, so I hope you've already answered your question, but I just stumbled on it and just started researching this myself and figured I'd reopen the conversation in case anyone else is trying the same thing.

I found a part of the Actor Component where it detects if the actor is hitting a ceiling or a wall. If you open ActorComponent.cs and search for "hit a wall" you should find a piece of code that looks like this:

// if object was not a ground surface...
            if (!groundSurface)
            {
                // notify the controller that we hit a wall
                if (Controller as ActorController != null)
                    (Controller as ActorController).ActorHitWall(this, info, dot);

I haven't played with this very much, but it seems like when you hit something the code checks if you're colliding with the ground, and if you aren't then it means you're hitting a wall or ceiling. However, it doesn't seem to tell you which of those two (the wall or ceiling) you're hitting. My next step is to see if I can add that to this function.
#2
10/03/2008 (1:11 pm)
Yep I had this problem, but then in the end didn't need this code as gameplay changed. I added code that check the wall's or roof's x and y and compare it to the actor's position, but that had the problem that if the object the actor collided with was large and complex the x,y was not very accurate, as the centre does mean much.

What you can do is compare the collision info's vector position to the actor's. This should determine if the actor collided against a wall or hit the roof.