Game Development Community

Issue with CastCollision in Torque 1.7.4

by MoCubed · in Torque Game Builder · 02/25/2009 (5:14 am) · 4 replies

Is there like a specific forum for newbie coding questions in Torque Game Builder? Hopefully no one has a problem with me making new threads every time I have a question I can't solve by searching or Documentation scouring.

I just upgraded to Torque 1.7.4 and have been running into a number of problems with my collision detection that is deterring from my real efforts. After the change, when I bump into a wall, my controls become frozen and I cannot change direction. When I jump and land, I can't move. I had a method to initialize the object to its standing state when colliding with an object, but now castCollsion method is not filling any variables, all of a sudden. My walls, floor, and player are all set to Clamp collisions, and (almost) everything was working okay in Torque 1.6.

Can anyone shed some light on the matter? Also, is there like some forum or IRC channel (as if I knew how to use IRC) just for general conversations about Torque coding methods and stuff? Agile at work has made me almost useless on my own <-P. Thank you in advance.

Jarid Cole

#1
02/25/2009 (2:44 pm)
Then dont upgrade. Actually higher version of TGB means more bugs. So best version is 1.1.3.
#2
02/25/2009 (2:52 pm)
Quote:Then dont upgrade. Actually higher version of TGB means more bugs. So best version is 1.1.3.

Where on earth did you get this idea?

Jarid, I suspect that castCollision isn't the best method to use. Explain how any why you are using it, then we might be able to find a better solution for you!
#3
02/25/2009 (3:05 pm)
From my own experineces... And lots of published games are made in 1.1.3 for some reason.
#4
02/26/2009 (4:36 am)
Thanks for the replies.

Essentially, I am trying to run a platformer based on the code found in the tutorial here. I realize now that there has been an update, removing the cast collision from the horizontal and vertical motion, but I implemented it in my game using the old suggestions.

function Character::updateMotion(%this)
{   
    %xVelocity = %this.getLinearVelocityX();
    
    %collision = %this.castCollision(0.020);
    %normalX = getWord(%collision, 4);
    %normalY = getWord(%collision, 5);
	
    $Logger.debug(getWord(%collision, 0));
	
    if (%this.moving)
    {
        //if we are moving horizontally
        if ((%xVelocity > 0 && %normalX == -1) ||
            (%xVelocity < 0 && %normalX == 1)  ||
            (%yVelocity != 0 && %normalY == 1))
        {			
            %this.stopMoving();
        }
        else if (%normalX == 0 && %normalY == -1)
        {
            //we have hit our head on something above us, and not our sides
            //stop the object's upward motion, and let our ConstantForce do the rest
            %this.setLinearVelocityY(0);
        }
        else
        {
            %this.airborne = false;
        }
    }
}
When you press a movement key, all it does is set the correct linear velocity and set a flag that you are moving to true. StopMoving() does nothing more than put the player back into the standing state (flags turned off, animation set correctly). It should be pretty simple processing, especially since I can't risk bogging the system down before everything else happens.

Either way, responding here has given me a lead, so I'm going to try that tutorial update as well. If anyone has a better process I'd be glad to hear it. Thank you for your time.

Jarid