Game Development Community

Moving an object, and containerRayCast

by Brian Burke · in Torque 3D Professional · 02/15/2011 (3:23 pm) · 4 replies

Maybe someone here can point out what I'm doing wrong here.

I'm trying to make my server-side script find where an in-game object is pointing with the containerRayCast(..) call.

The return value from containerRayCast(..) is split up into a point and a normal, which I understand to be the point where the ray intersects an object, and the surface normal from where it hit. The normal looks approximately correct, but I'm not convinced that the position is correct.

... So what I'm trying to do is place an object at that point so I can visualize it. This is where I hit a wall. I set up a particle emitter emitting some smoke, and I set my script to move it around ... or so I thought.

%T = setWord(%T, 0, %ContactPoint);
%T = setWord(%T, 3, "0 0 1 0");
echo( "T : ", %T );   
   
TestParticles.setTransform(%T);

The value that gets 'echo'ed looks reasonable to me. And if I do a getTransform, I get back the value I just set. However, the actual emitter that I can see in the game just sits there and doesn't move.

Is there some sort of update call I need to do to make those values 'stick'?

Any help appreciated, Thanks.

-Andy

#1
02/15/2011 (3:54 pm)
Andy, which version of T3D are you using? And to make sure, you are taking into account that the first word is the ID of the object struck by the ray cast? If so, try to compare the ID returned with the ID of the object you are trying to hit. Also I believe there is an issue with client side casting versus server side casting, so you might want to explore running it server side as well if you are not currently doing so.
#2
02/15/2011 (4:35 pm)
You are performing this serverside which is correct, but as Ryan mentioned, your return values might be getting handled incorrectly...

getWord(%ret, 0) is your object ID
getWords(%ret, 1, 3) is your position
getWords(%ret, 4, 6) is your normal
#3
02/16/2011 (2:24 am)
hey Andy,the best way to debug rays is to draw lines in space.
It also depends on what you hit.For example if you hit an animated staticshape your position could be wrong,because animation happens on the client,but you call containerRayCast() on the serverside scripts.
#4
02/16/2011 (2:51 am)
I think the issue here is that the particle emitter isn't moving to the location returned by the raycast.

Try using a StaticShape for now - it might be something dodgy with the emitter net code.