Game Development Community

CastCollision (mount?) problem

by Backman · in Torque Game Builder · 06/25/2007 (1:26 am) · 4 replies

Hello, I'm trying to use castcollision as a way to check what's to the left and right of my object before moving there. I'm using what I imagine is the usual way...

$blockGroup.setLinearVelocityX(-50); //check left
%collision = %this.castCollision(0.01);
$blockGroup.setLinearVelocityX(0);

%collision now returns 0 even tho there's an object to its left.

%this is an individual block which is mounted to $blockGroup. It's giving me big headaches as it just won't see the objects to its left or right this way. It was working before I mounted the individual block to the blockgroup. It just can't see anything unless it's already on top of it.

The only explanation I can think of is that setting a velocity to the mountparent isn't fast enough to get the velocity through to its mounts/children on the next line..

Has anyone come across something like this before?

Thanks.

#1
06/25/2007 (4:31 am)
Try castcollision 0.05 instead of 0.01

I think the number pertains to time and hence its checking it very fast.

I tried using 0.01 and even I had the same problem( but not with mounted objects). Currently I am using 0.05 and its working well.
#2
06/25/2007 (6:34 am)
0.01 in this setup would check -0.5 in x direction for collision ... not very high chance to hit something there.
#3
06/25/2007 (12:20 pm)
Ok thanks... neat actually, didn't realize the connection between velocity and time. Will try tweaking the values more, those numbers there are just one combination I tried but with that explanation I might've been too careful.

Cheers.
#4
06/26/2007 (12:52 am)
For anyone struggling to cast collision from objects that are mounted.. dismounting the object from its parent was the only thing that worked for me. A bit annoying, can only assume that mounted object positions don't get their positions updated by parent movement until sceneupdate?

It's quite clear that even using setPosition on the parent doesn't effect the mount/child position if it's on the next line. Does now though. :)

Thanks for the help, slowly learning.