Author Topic: setVelocity not working? [Solved]  (Read 1685 times)

There's a specific part of my code where setVelocity is not working, but I have no clue why.
Code: [Select]
%start = vectorAdd(%obj.getEyePoint(),"0 0 -0.5");
%beam = vectorScale(%obj.getEyeVector(),15);
%end = vectorAdd(%start, %beam);
%ray = containerRayCast(%start, %end, $TypeMasks::fxBrickObjectType | $Typemasks::TerrainObjectType | $Typemasks::VehicleObjectType, %obj);
if(isObject(%colC = firstWord(%ray)))
{
talk("looking at target & nothing in the way");
%eyeVec = %obj.getEyeVector();
%dive = vectorScale(%eyeVec,10);
%obj.setVelocity(vectorAdd(vectorScale(%vec,5),"0 0 10"));
%obj.schedule(400,setVelocity,%dive);
}
« Last Edit: April 08, 2013, 09:58:24 AM by tommybricksetti »


You may want to learn more about velocity here: http://forum.blockland.us/index.php?topic=224122.0
thanks but I need velocity not vectors. Also my code should work perfectly, but it's not for some reason.

Well you're using a variable you never apparently defined, "%vec" in there. If that's not it, you're gonna have to be more specific with what it currently does.

Well you're using a variable you never apparently defined, "%vec" in there. If that's not it, you're gonna have to be more specific with what it currently does.
%vec is defined, but the function is really long. I tested the dive function elsewhere, in another script, and it worked fine. I really don't know what's happening.

You'll still need to be more specific. How does it not work? Does the talk show up properly? Do you move at all?

You'll still need to be more specific. How does it not work? Does the talk show up properly? Do you move at all?
ah you don't move at all. The talk works. And if I add a playthread that works too.

ah you don't move at all. The talk works. And if I add a playthread that works too.
Do you stop moving if you're moving already? Try separating vectorAdd(vectorScale(%vec,5),"0 0 10") into its own variable and echoing it.

Do you stop moving if you're moving already? Try separating vectorAdd(vectorScale(%vec,5),"0 0 10") into its own variable and echoing it.
K it echos correctly. still nothing tho. Could you get on Bl, so I can show you?

Solved. For some reason it was setTransforming onFire. So I added a slight setTransform of 0.1 to override that.

Solved. For some reason it was setTransforming onFire. So I added a slight setTransform of 0.1 to override that.

Uh.. setTransform doesn't reset velocity.