Author Topic: Creating Zones Ghosting Issue [Solved]  (Read 417 times)

I'm making a script that lets player hover in one spot, i.e. hang from a ledge. I was using just setVelocity before, but it was pretty shaky, so I decided to try zones. The problem now is that every 2-4 seconds it says ghosting, and the zones stop creating temporarily. The solution I was thinking of is to create one zone, and transform it to the player's location continuously. I do not, however, know how to do this. Here's my code so far:
Code: [Select]
function Player::GrabPlace(%obj)
{
if(%obj.isJumping)
{
%obj.schedule(5,HoldPlace);
%obj.addVelocity(vectorScale(%obj.getForwardVector(),1));
%vel = %obj.getVelocity();
%upv = getWord(%vel,2);
if(%upv < 0.645)
{
%obj.setVelocity("0 0 0.655");
}
if(!%obj.isAnim)
{
%obj.playthread(3,fall);
%obj.playthread(2,armreadyboth);
%obj.changedatablock(PlayerSleepingDogsClimb);
%obj.isAnim=1;
}
}
}

function Player::GrabZone(%obj)
{
if(%obj.isJumping)
{
%zoneShape = "1.5 1.5 3";
%position = %obj.getPosition();
%newZone = new PhysicalZone()
{
velocityMod = "0.0";
gravityMod = "0.0";
extraDrag = "0";
};
missionCleanup.add(%newZone);
%newZone.setTransform(%position);
%newZone.schedule(5,delete);
}
}

function Player::HoldPlace(%obj)
{
    %start = %obj.getHackPosition();
    %beam = vectorScale(%obj.getForwardVector(),0.65);
%end = vectorAdd(%start, %beam);
%ray = containerRayCast(%start, %end, $TypeMasks::fxBrickObjectType, %obj);
if(!isObject(%col = firstWord(%ray)))
{
%obj.schedule(5,HoldPlace);
}
else
{
%start = %obj.getEyePoint();
%beam = vectorScale(%obj.getForwardVector(),0.55);
%end = vectorAdd(%start, %beam);
%ray = containerRayCast(%start, %end, $TypeMasks::fxBrickObjectType, %obj);
if(!isObject(%col = firstWord(%ray)))
{
%obj.GrabPlace();
%obj.GrabZone();
}
else
{
%obj.schedule(5,HoldPlace);
}
}
}
« Last Edit: January 25, 2013, 11:01:00 PM by tommybricksetti »

Never mind, figured out how to do it:
Code: [Select]
function Player::GrabZone(%obj)
{
if(%obj.isJumping)
{
%position = %obj.getPosition();
if(!%obj.isAnim)
{
%newZone = new PhysicalZone()
{
velocityMod = "0.0";
gravityMod = "0.0";
extraDrag = "0";
};
missionCleanup.add(%newZone);
}
%newZone.setTransform(%position);
%newZone.schedule(5,ZoneKill);
}
}