How to make the player a movable RigidShape?
by Khalid Abuhakmeh · in Torque Game Engine · 04/05/2005 (11:39 am) · 3 replies
Ok, I'm new here, but I'm making a game for class where I would like the player to be a sphere (yes, somewhat like Marble Blast, but not exactly the same thing). I found the Rigid Shape class and recompiled the engine with that, but now I can't seem to figure out how to modify the base tutorial to use a Rigid Shape sphere for the player instead of that green alien guy. I got it to load the sphere, but hitting the WASD keys doesn't move the sphere around at all. I can pick it up and it will roll away on its own if it's on a slope, but you can't control it.
Here are the only parts of the scripts I've changed:
And...
Here are the only parts of the scripts I've changed:
datablock RigidShapeData(BouncingBall)
{
category = "RigidShape";
shapeFile = "~/data/shapes/player/sphere.dts";
emap = true;
// Rigid Body
mass = 500;
massCenter = "0 0 0"; // Center of mass for rigid body
massBox = "0 0 0"; // Size of box used for moment of inertia,
// if zero it defaults to object bounding box
drag = 0.2; // Drag coefficient
bodyFriction = 0.2;
bodyRestitution = 0.1;
minImpactSpeed = 5; // Impacts over this invoke the script callback
softImpactSpeed = 5; // Play SoftImpact Sound
hardImpactSpeed = 15; // Play HardImpact Sound
integration = 4; // Physics integration: TickSec/Rate
collisionTol = 0.1; // Collision distance tolerance
contactTol = 0.1; // Contact velocity tolerance
minRollSpeed = 10;
maxDrag = 0.5;
minDrag = 0.01;
triggerDustHeight = 1;
dustHeight = 10;
dragForce = 0.05;
vertFactor = 0.05;
normalForce = 0.05;
restorativeForce = 0.05;
rollForce = 0.05;
pitchForce = 0.05;
computeCRC = true;
canObserve = true;
cmdCategory = "Clients";
cameraDefaultFov = 90.0;
cameraMinFov = 5.0;
cameraMaxFov = 120.0;
minLookAngle = -1.4;
maxLookAngle = 1.4;
maxFreelookAngle = 3.0;
jumpForce = 8.3 * 90;
jumpEnergyDrain = 0;
minJumpEnergy = 0;
jumpDelay = 15;
minJumpSpeed = 20;
maxJumpSpeed = 30;
};And...
function GameConnection::createPlayer(%this, %spawnPoint)
{
if (%this.player > 0)
{
// The client should not have a player currently
// assigned. Assigning a new one could result in
// a player ghost.
error( "Attempting to create an angus ghost!" );
}
// Create the player object
// %player = new Player() {
// dataBlock = PlayerShape;
// client = %this;
// };
// Create the player object
%player = new RigidShape()
{
dataBlock = BouncingBall;
client = %this;
};
MissionCleanup.add(%player);
// Player setup...
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
// Update the camera to start with the player
%this.camera.setTransform(%player.getEyeTransform());
// Give the client control of the player
%this.player = %player;
%this.setControlObject(%player);
}
#2
and this
Also remove
category=RigidShape
04/06/2005 (8:55 am)
Or even simpler just replace thisdatablock RigidShapeData(BouncingBall)with
datablock PlayerData(BouncingBall)
and this
%player = new RigidShape();With this
%player = new BouncingBall();
Also remove
category=RigidShape
#3
I tried your suggestion, but I get the following error now:
Unable to instantiate non-conobject class BouncingBall.
So, I think it's a little bit more complicated than that.
04/06/2005 (2:48 pm)
Dreamer:I tried your suggestion, but I get the following error now:
Unable to instantiate non-conobject class BouncingBall.
So, I think it's a little bit more complicated than that.
Associate Anthony Rosenbaum
You will probably have to adjust it's Updatemove() function to respond to key presses.
Try porting the player's update move into the rigidShape equivallent.