Author Topic: Playertype velocity problems  (Read 1411 times)

%p = new AIPlayer()
{
   dataBlock = PuckArmor;
   position = %obj.getMuzzlePoint(%slot);
   sourceObject = %obj;
   sourceSlot = %slot;
};
%p.setVelocity(%vel);

why doesn't this work

base/server/scripts/allGameScripts.cs (11100): Unable to find object: '17021' at
tempting to call function 'setRepairRate'
BackTrace: ->HockeyStickWPuckImage::onFire->PuckArmor::onAdd->[BotHolePackage]ar
mor::onAdd->[sportBallsPackage]armor::onAdd->armor::onAdd
%
%
Add-Ons/Item_Hockey/Item_HockeyStick.cs (221): Unable to find object: '17021' at
tempting to call function 'setVelocity'
BackTrace: ->HockeyStickWPuckImage::onFire


figured this out

and how does one detect when PuckArmor is clicked?

« Last Edit: June 09, 2013, 09:30:12 AM by Aide33 »

and how does one detect when PuckArmor is clicked?
container raycast


can you explain how

Use the function containerRayCast. Think of it as creating a virtual line between two points, running over the line and stopping if it hits an object's container on the way. It takes either three or four arguments, those being:

  • start; the position of the start point of the line
  • end; the position of the end point of the line
  • mask; a bitfield typically constructed by combining values from $TypeMasks::* with binary OR
  • avoid (optional); an object whose container to ignore when traversing the line

If it hits an object, it will return a string containing various information about it, as separated words. The only word you really would need to consider is the first one, which is the object that was hit. If it doesn't hit anything, it returns 0.

In your case, you could start at the eye point of a player when they click, end at a point further along their eye vector and avoid the player themselves.
« Last Edit: June 10, 2013, 02:33:33 AM by Port »

I believe avoid can be multiple things, in fact I remember it being inside dumpConsoleFuncs...

Code: [Select]
... virtual string containerRayCast( Point3F start, Point3F end, bitset mask, SceneObject exempt=NULL,exempt2,exempt3,exempt4,exempt5,exempt6 ) {} ...
That's really not important right now though. Just pointing it out.

Even though Port did a nice job summing up what raycasts do and how to use them, you must still be wondering how to implement it so that it activates when a player clicks. It's really easy- you can just package player::activateStuff(), do the vector math, and trace from there. Here's an example that I wrote from the top of my head:

Code: [Select]

package activateStuffPackage
{
        function Player::activateStuff(%player)
{
%lengthOfRay = 4;

%start = %player.getEyePoint();
%end = vectorAdd(%start, vectorScale(%player.getEyeVector(), %lengthOfRay));

%hit = containerRayCast(%start, %end, $TypeMasks::PlayerObjectType, %player);

if(!isObject(%hit))
{
return Parent::activateStuff(%player);
}

//do checks & stuff to %hit

return Parent::activateStuff(%player);
}
};


Double post

Wouldn't that break activating bricks?
Whats the Typemask for bricks and other stuff


found a typemasks list nvm
« Last Edit: June 11, 2013, 05:40:56 PM by Aide33 »