Simple rotating block
by Sam Burns · in Torque Game Engine · 07/27/2008 (8:02 am) · 1 replies
Hi
I'm a bit of a noob at all this so please be gentle. Basically I am exploring the torque engine by trying to implement a simple little 3d platformer. If you think sort of the bonus levels in Mario Sunshine. I have implemented a rotating block which the player has to run across without falling off. I have done it with a StaticShape and programmatically rotated it.
Now if I run across it I will get to the end. But if I stop I would expect the angle to get too great for the avatar to maintain its footing and it should slide off. However what seems to be happening is that as soon as I stop, the avatar falls straight down through the block. I thought this may be a problem with the collision box not rotating with the block model. But if I watch it in the level editor it seems to be fine.
Is this something that will require a bit of modification to the the torque engine? Reading about Marble Blast in TDN suggested that they needed to update the physics side of things to get it to run right which I would imagine is along similar grounds to my game.
I'm using TGE 1.5.2 atm
Any pointers would be greatly appreciated. I understand that the default physics set up will not be suitable for my game but this seems to be a rather fundamental problem. Below is the script I am using.
datablock StaticShapeData(Platform)
{
className = "RotatingPlatform";
category = "Obstacle";
shapeFile = "~/data/shapes/platform/platform.dts";
mass = 1.0;
drag = 0.3;
density =1.0;
friction = 1.0;
gravityMod = 0.0; //make sure it stays in the air
};
function Platform::onAdd(%this,%obj)
{
//if(false)
rotateBlock(%obj, 0.01);
}
function rotateBlock(%shape, %angle)
{
%xfrm = %shape.getTransform();
%lx = getWord(%xfrm, 0);
%ly = getWord(%xfrm, 1);
%lz = getWord(%xfrm, 2);
%angle += 0.005;
%rd = %angle;
%shape.setTransform( %lx SPC %ly SPC %lz SPC 0.0 SPC 1.0 SPC 0.0 SPC %rd );
schedule(5, 0, RotateBlock, %shape, %angle);
}
I'm a bit of a noob at all this so please be gentle. Basically I am exploring the torque engine by trying to implement a simple little 3d platformer. If you think sort of the bonus levels in Mario Sunshine. I have implemented a rotating block which the player has to run across without falling off. I have done it with a StaticShape and programmatically rotated it.
Now if I run across it I will get to the end. But if I stop I would expect the angle to get too great for the avatar to maintain its footing and it should slide off. However what seems to be happening is that as soon as I stop, the avatar falls straight down through the block. I thought this may be a problem with the collision box not rotating with the block model. But if I watch it in the level editor it seems to be fine.
Is this something that will require a bit of modification to the the torque engine? Reading about Marble Blast in TDN suggested that they needed to update the physics side of things to get it to run right which I would imagine is along similar grounds to my game.
I'm using TGE 1.5.2 atm
Any pointers would be greatly appreciated. I understand that the default physics set up will not be suitable for my game but this seems to be a rather fundamental problem. Below is the script I am using.
datablock StaticShapeData(Platform)
{
className = "RotatingPlatform";
category = "Obstacle";
shapeFile = "~/data/shapes/platform/platform.dts";
mass = 1.0;
drag = 0.3;
density =1.0;
friction = 1.0;
gravityMod = 0.0; //make sure it stays in the air
};
function Platform::onAdd(%this,%obj)
{
//if(false)
rotateBlock(%obj, 0.01);
}
function rotateBlock(%shape, %angle)
{
%xfrm = %shape.getTransform();
%lx = getWord(%xfrm, 0);
%ly = getWord(%xfrm, 1);
%lz = getWord(%xfrm, 2);
%angle += 0.005;
%rd = %angle;
%shape.setTransform( %lx SPC %ly SPC %lz SPC 0.0 SPC 1.0 SPC 0.0 SPC %rd );
schedule(5, 0, RotateBlock, %shape, %angle);
}
About the author
Torque 3D Owner Dan Keller
Default Studio Name