Author Topic: Cannot Move Object  (Read 1465 times)

I am having a lot of trouble getting my object to move. I have tried %obj.shape.transform(%pos); and even deleting it and creating a new one. For some reason, however, it only moves once and then stays there. I don't understand because I've tried static shapes and vehicles both. Help would be much appreciated.
Code: [Select]
//ClimbTool
datablock StaticShapeData(ClimbToolData)
{
category = "Static Shapes";
shapeFile = "./cube_col.dts";
};
datablock StaticShapeData(ClimbBrickData)
{
shapeFile = "base/data/shapes/bricks/2x2fround.dts";
};
datablock WheeledVehicleData(ClimbVehicle)
{
   category = "Vehicles";
   shapeFile = "base/data/shapes/bricks/2x2fround.dts";
   emap = true;
   maxDamage = 1000.0;
   destroyedLevel = 1000.0;
   mass = 0; //3100 lbs
   density = 0.5;
   massCenter = "0.0 0.0 0.5";    // Center of mass for rigid body
   massBox = "1.5 1.5 1.5";         // Size of box used for moment of inertia,
                              // if zero it defaults to object bounding box
   drag = 0.8;                // Drag coefficient
   bodyFriction = 0.21;
   bodyRestitution = 0.2;
   minImpactSpeed = 3;        // Impacts over this invoke the script callback
   softImpactSpeed = 3;       // Play SoftImpact Sound
   hardImpactSpeed = 10;      // Play HardImpact Sound
   integration = 10;           // Physics integration: TickSec/Rate
   collisionTol = 0.1;        // Collision distance tolerance
   contactTol = 0.01;          // Contact velocity tolerance
   engineTorque = 00;       // Engine power
   engineBrake = 00;         // Braking when throttle is 0
   brakeTorque = 00;        // When brakes are applied
   maxWheelSpeed = 00;        // Engine scale by current speed / max speed

forwardThrust = 00;
reverseThrust = 00;
lift = 0;
maxForwardVel = 00;
maxReverseVel = 00;
horizontalSurfaceForce = 0;   // Horizontal center "wing" (provides "bite" into the wind for climbing/diving and turning)
verticalSurfaceForce = 0;
rollForce = 00;
yawForce = 00;
pitchForce = 00;
rotationalDrag = 0;
stallSpeed = 0;
};

Code: [Select]
//Shape
function Player::SpawnAShape(%obj)
{
if(%obj.isHanging)
{
%pos = vectorAdd(%obj.getPosition(),"0 0 0.1");
}
else if(!%obj.isAnim && %obj.isClimbing)
{
%pos = vectorAdd(%obj.getPosition(),"0 0 -1");
}
%obj.ShapeDelete();
%nPos = vectorAdd(%pos,"0 0 -0.3");
%obj.shape = new WheeledVehicle()
{
datablock = ClimbVehicle;
// position = vectorAdd(%pos,"0 0 -0.35");
client = %obj.client;
// scale = "0.5 0.5 0.1";
};
%obj.shape.setTransform(%nPos);
%obj.isShaping=1;
}
function Player::moveShape(%obj)
{
// talk("moveShape called");
if(%obj.isShaping)
{
%pos = vectorAdd(%obj.getPosition(),"0 0 0.1");
%nPos = vectorAdd(%pos,"0 0 -0.3");
%sPos = %obj.shape.getPosition();
%obj.shape.setTransform(%nPos);
// echo(%sPos);
// talk(%sPos);
// echo(%pos);
// talk(%pos);
}
}
function Player::ShapeDelete(%obj)
{
if(%obj.isShaping)
{
// talk("ClimbTool deleted");
%obj.isShapinging=0;
%obj.shape.delete();
}
}

I do not see where Player::moveShape is being called.

that's in another part of the script. But I have talks to to make sure it's being called.

%obj.shape.transform(%pos);

  • PhysicalObject::Transform(%trans); is not a function. Try .SetTransform(%trans); instead.
  • Sounds like you're calling this object from another object. Ensure the variable isn't changed or overridden.

  • PhysicalObject::Transform(%trans); is not a function. Try .SetTransform(%trans); instead.
  • Sounds like you're calling this object from another object. Ensure the variable isn't changed or overridden.
If you looked at his code, you'd notice he is using the setTransform method. Probably just a typo in his intro explanation.

Do you mean to move things instantly?  I sometimes use findclientbyname("Dglider").player.position = "# # #"; to move myself around to specific points.  Maybe that will help.