Skip to content

Toolset Vectors not plotting properly.

A friend of mine is having an issue that I'm really hoping one of you fine folk can help him fix.

He's using transformobject to simulate a jump between two objects, what should be a simple (x,y)-(x2,y2) multiplies into a number of problems with facing. He's slammed his head against it for days with the best result giving him 2/4 directions working and the other 2 sending you off into oblivion.

When it works, the object moves to the other object. Other times it veers off in the wrong direction. Could be he's making a simple mistake that he's gone blind to considering the time he's spent trying to make this work.

He's trying for a more dynamic range, using it for abilities and spells as well as standard jump triggers

He set up a function to get the change in X and Y with
vector vOrigin = GetPositionFromLocation(lOrigin);
vector vTarget = GetPositionFromLocation(lTarget);
float fY;
fY = vOrigin.y-vTarget.y;
Theres a duplicate function for x with appropriate changes.

(I'm asking for him, because he's being too prideful, and he figures that if I ask, its not HIM asking for help. I have direct contact with him, and I can ask him anything that might be needed, because he is aware I a asking for him.)

Comments

  • TarotRedhandTarotRedhand Member Posts: 1,481
    edited August 2022
    float fY;
    fY = vOrigin.y-vTarget.y;
    

    Will only give the y distance between the two points and depending on the two y's could be a negative number. Can you post the whole function(s) in question please so we can see what is going on.

    Why not use -
    void JumpToLocation(location locDestination);
    
    instead?

    TR
  • HydroMeranoHydroMerano Member Posts: 2
    Sorry this is good now, it can be closed. My buddy decided to go with Arctangents instead. (He also tried that, but it kept facing "true" north so the jump looked off, NwN facing and whatnot.) Thanks for the advice though!
  • ProlericProleric Member Posts: 1,281
    A jump action followed by ActionDoCommand(SetFacing(...)) will do the job if an instant movement is required.

    When using a timed series of visual transformations to create the illusion of motion, those actions come last.

    Vector math in NWScript generally works fine, though IIRC the axis labels for the visual transformation function are confusing.
Sign In or Register to comment.