Game Development Community

Item triggering mountimage on a vehicle?

by Lee Latham · in Torque Game Engine · 01/25/2007 (10:35 pm) · 1 replies

Hello,

I'm trying to something which I thought was very simple, but I must have something wrong in my head, and would appreciate someone smarter than me pointing me in the right direction.

I thought it would be nice to have an Item, and when a vehicle drives through it, a static shape gets mounted on the vehicle. I've defined a shape datablock (I've tried both StaticShapeData and ShapeBaseImageData) and I'm trying to do the mount in the Item::onCollision function. I'm wondering if that's my problem...?

Anyway I've done some basic testing and I've identified the vehicle (%col in this function) and I can even do other things to the vehicle when it goes through the Item, but the mount fails silently. No error message...nothin. Tried using some other existing shapes, like the crossbow for example, with no luck.

btw I'm using the bravetree car, but with a weapon mounted on mount1. I've added an 8th mountpoint for this thingy. I've tried mounting to different places and such with no luck.

Any input would be greatly appreciated!

Lee

#1
01/25/2007 (10:51 pm)
Never mind, I got it! LOL

What I didn't understand was the relationship between the mountpoint declared in the ShapeBaseImageData datablock and the mountpoint indicated in the MountImage command. Basically, it appears that you should always mount to 0 in the command, and the mountpoint in the datablock will override this? It would still be nice if someone could explain this to me. Obviously, I'm no coder.

But for posterity, here is what worked for me (simplified slightly for clarity):
datablock ShapeBaseImageData(myshape)
{
   // Basic Item properties
   shapeFile = "~/data/shapes/pathto/mydts.dts";
   emap = true;
mountPoint = 8;

};

function myitem::onCollision(%this,%obj,%col)
{

    %col.mountImage(myshape,0);
}

This caused myshape to be mounted to mount8 on the car when it drove through the item.
lee