Jump to content

WaxyChicken

Members
  • Posts

    8
  • Joined

  • Last visited

About WaxyChicken

  • Birthday 04/01/1975

WaxyChicken's Achievements

  1. oops. never mind. Current Object .... Current TARGET
  2. My turrets keep shooting at RigidShape objects (eg: the boulders) so in the code i tell it to add RigidShapes to it's Ignore List. The turret takes aim at the object, the script kicks in... and the game crashes. why? %obj = turret %CurrentTarget = %obj.getTarget(); if(isObject(%CurrentTarget)) { if(%CurrentTarget.getClassName() $= "RigidShape") { %obj.addToIgnoreList(%CurrentObject); // <--- this line crashes game } }
  3. nice try, Doc, but freezesim() is part of RigidShape inheritance. AITurretShape and RigidShape both use ShapeBase, but AITurretShape doesn't use RigidShape - it's a different branch of the inheritance shape. RigidShape inheritence: http://docs.garagegames.com/torque-3d/reference/classRigidShape__inherit__graph.png AITurretShape Inheritence: http://docs.garagegames.com/torque-3d/reference/classAITurretShape__inherit__graph.png full list of all AITurretShape functions/values can be found here: http://docs.garagegames.com/torque-3d/reference/classAITurretShape-members.html (is this up to date with 3.6.1? i don't know)
  4. Sometimes, yes. and there MUST be a way for the engine to enable / disable the sticky quality on the fly because, well, the editor does it. The editor can dynamically change the "Sticky" value of an object in real time. just test with creating a sticky... unsticky... resticky in the editor. unfortunately I'm not talented enough to understand how it's doing it.
  5. DeployableAITurret / AITurret datablock AITurretShapeData(ReactorDeployableTurret : ReactorAITurret) datablock AITurretShapeData(ReactorAITurret) datablock ShapeBaseImageData(ReactorDeployableTurretImage) http://s26.postimg.org/t6tiplfq1/Turrets.png
  6. How can you change the sticky setting of an object through torque script? i am attempting to make objects that the players can move around and then "Set" once they choose a location. I've tried %obj.sticky = true; %obj.stickToGround(); and i tried %TempDataBlock = %obj.getDataBlock(); %TempDataBlock.sticky = true; %obj.setDataBlock(%TempDataBlock); no luck.
  7. In this version of Torque3D MIT (v3.6.1) there is still the problem of aircraft getting stuck in terrain or other objects. such as when you land an aircraft at low speeds and it slowly drifts into a wall and "Gets Stuck". These code tweaks will help to automatically "UNSTICK" your stuck aircraft. using your editor add these dynamic values into your vehicle datablock: lastColVec = 0 0 0 lastColVecB = 1 1 1 unstickMeter = 0 in your scripts: scripts / server / vehicle.cs function VehicleData::onAdd(%this, %obj) { %obj.setRechargeRate(%this.rechargeRate); %obj.setEnergyLevel(%this.MaxEnergy); %obj.setRepairRate(0); if (%obj.mountable || %obj.mountable $= "") %this.isMountable(%obj, true); else %this.isMountable(%obj, false); if (%this.nameTag !$= "") %obj.setShapeName(%this.nameTag); if (%obj.getClassName() $= "FlyingVehicle") %this.CheckForStuck(%obj); }because it tends to occur with only flying vehicles, adding in if (%obj.getClassName() == "FlyingVehcile") will make it apply only to flying vehicles. %this.CheckForStuck(%obj); is the call that will start it's routine checking for getting stuck, and pushing the vehicle back when a sticky situation is detected. these values are managed by the onCollision and onImapct functions: function VehicleData::onCollision(%this, %obj, %sourceObject, %position, %len) { %tempPosition = %obj.getPosition(); if (%obj.lastColVec !$= %tempPosition) { %obj.lastColVecB = %obj.lastColVec; %obj.lastColVec = %tempPosition; } } function VehicleData::onImpact(%this, %obj, %sourceObject, %position, %len) { %tempPosition = %obj.getPosition(); if (%obj.lastColVec !$= %tempPosition) { %obj.lastColVecB = %obj.lastColVec; %obj.lastColVec = %tempPosition; } } during any contact with another object - collision or full impact speed - the position the the craft will now be stored in the datablock. this will provide "Rewind" values. We will get to that later. For now, add in the function that does the actual hard work: function VehicleData::CheckForStuck(%this,%obj) { //Make sure this vehicle still exists. return if it doesn't. if(!isObject(%obj) ) { return; } %Vehiclepos = %obj.getPosition(); if (%Vehiclepos $= %obj.UnstickPosition) { // the vehicle is stuck!?! // let it check a couple more times on our sticky meeter to make sure. %obj.unstickMeter = %obj.unstickMeter + 1; if (%obj.unstickMeter > 2) { // echo (" ============== ATTEMPTING TO UNSTICK! ---"); if (%obj.unstickMeter > 5) { // UNSTICK IS NOT WORKING! // you may wish to add code to destroy the vehicle or kill the player at this point. %obj.unstickMeter = 5; } // let's check our two history variables for a previous nearby collision // and set vehicle back to that position. // it will either bump lose quickly or "Shake" loose. if (%vehiclepos $= %obj.lastColVec) { %newPosition = %obj.lastColVecB; } else { %newPosition = %obj.lastColVec; } // echo ("Unstick Attempt - change " @ %vehiclepos @ " to " @ %newPosition); %obj.setTransform(%newPosition)); } } else { %obj.unstickMeter = 0; %obj.unstickPosition = %VehiclePos; } if ( isObject(%obj) ) { // decrease the 250 to a lower number for a faster response to sticking but more burden on the server / hosting client. %this.schedule(250,CheckForStuck,%obj); } else { // at some point during this function the vehicle was removed or destroyed. // echo("\c1 Vehicle::: DESTROYED!"); } } i find this working on aircraft datablocks with the following values: bodyRestitution = 1 bodyFriction = 0.1 collisionTol = 1 contactTol = 1 this is intended only for vehicles that have a minimum speed > 0 (even if they are just wiggling in place) this is not a "TRUE" solution or a perfect fix, but it does make getting stuck MUCH more rare and with some tweaking you may get better results.
×
×
  • Create New...