Need help with 3D 360 movement

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • This doesn't specifically relate to MMF2 but it relates to coding and this is the community forum, after all.

    I need help with how to go about moving an object in a straight line towards a point in a 3D enviornment, like going from (1,7,4) to (45,3,62) where the Y value is the height off the ground. So far I can find an angle on the XZ plane, but now where am I suppost to go? Any and all help appriciated.

    So far I have code that is similar to this: (though the syntax is compltely different because it is for a game I play)

    XZ_Dir = atan2(( Target X Position - Current X Position ), ( Current Z Position - Target Z Position ))*-1

    So I need to know how to go about this, because I haven't ever tried much outside of 2D.

    Thanks,
    -LB

    Working as fast as I can on Fusion 3

  • Ok, theres probably a few ways to do this, but this is what i came up with-

    You need to get the movement vector (or whatever its called, i forget). Which is basically the difference between your two positions.

    for the X --> 45-1 = 44
    for the Y --> 3-7 = -4
    for the Z --> 62-4 = 58

    so we have this new vector (44, -4 , 58)
    from this, we can draw some triangles and use trigonometry to work out the angles.

    see this image:

    Please login to see this picture.


    you should know that the TANGENT of an angle is equal to the OPPOSITE divided by the ADJACENT.

    so tan(x) = 4/44
    and tan(y) = 4/58

    this means that x = tan^-1 (-4/44)
    y = tan^-1 (-4/58)

    (tan^-1 means inverse of tan, most maths calculators can do this. so can MMF2)

    finally x = -1.72644 degrees
    y = -1.30971 degrees

    I hope this helped. And i hope I got it right...
    The theory is sound (I HOPE) even if i messed up somewhere. You simply get the angle in the XY dimension, then the angle in the YZ dimension. Both require the use of trig. However, if your in MMF2 you can probably use some extension that lets you get the angle between two points (however its just doing the exact same math as i just showed).

  • Aaah! You guys are making this way more complicated than it needs to be.

    If I understand your problem correctly, you just want to interpolate an object's position from one point to another. You don't even need to care about the angle for this problem.

    We have p1=(1,7,4) and p2=(45,3,62).

    So, the object's position can be calculated by:
    P = (1-n)p1 + np2.

    n is a decimal number between 0 and 1. When it's 0, P will be at p1. When it's 1, P will be at p2. When it's somewhere inbetween, the object will also be somewhere inbetween (proportional to the value of n).

    So, in order to do the interpolation, just add a little bit to n each frame (say, 0.01), and use that formula.

    Does that make sense? :]

    Please login to see this link. (Indie games and Fusion resources)
    For freelance inquiries please email admin at ultimatewalrus.com

  • Well, considering my expertise in math ends at 9th grade, and I read an article here on Sin and Cosin, I'd say that it's complicated to me. I will try to understand this, I read through to see which was closest to what I needed. Thanks, guys. :)

    Working as fast as I can on Fusion 3

  • Quote from LB

    my expertise in math ends at 9th grade

    In that case, I'd better elaborate on my previous post. :P

    Basically what I'm using is vector addition and multiplication. It's pretty straightforward --- you just have to know what it is.

    Vector addition
    (a,b,c) + (d,e,f) = (a+d, b+e, c+f)
    EX: (1,2,3) + (4,5,6) = (5,7,9)

    Vector multiplication
    n(a,b,c) = (n*a, n*b, n*c)
    EX: 3(1,2,3) = (3,6,9)

    Please login to see this link. (Indie games and Fusion resources)
    For freelance inquiries please email admin at ultimatewalrus.com

  • Quote from Jacob

    Does MMF2 Allow for commas like that? I didn't think it did.

    These aren't actual MMF expressions. Just math.

    Please login to see this link. (Indie games and Fusion resources)
    For freelance inquiries please email admin at ultimatewalrus.com

  • Yeah, I understand that. However, will it go faster the farther away it is? I can't test it because I am have troubles with invisible syntax errors that prevent it from running. I have no way of checking the syntax because it is a combonation of both XML and XS. If any experianced code programmer would like to have a look to see if they can find the problem, I'd be happy to show the code and explain it.

    And thanks again for helping me with this issue.

    Working as fast as I can on Fusion 3

  • Quote from LB

    Yeah, I understand that. However, will it go faster the farther away it is? I can't test it because I am have troubles with invisible syntax errors that prevent it from running. I have no way of checking the syntax because it is a combonation of both XML and XS. If any experianced code programmer would like to have a look to see if they can find the problem, I'd be happy to show the code and explain it.

    And thanks again for helping me with this issue.


    I'm experienced in XML. Don't know what XS is but I know many different scripting languages so it could be easy for me to understand.

    No, it won't go faster the farther away it is. If you increase n at a constant rate, the object will move at a constant rate. It doesn't matter how big or small n is; it's a linear function.

    Please login to see this link. (Indie games and Fusion resources)
    For freelance inquiries please email admin at ultimatewalrus.com

  • OK, XS is just like some variation of C but the game it's for has custom functions. I should warn you that setting an object's position is called 'teleporting', and a QV is a Quest Variable, just a regular floating point variable that the game lets you use.

    This is what it looks like in the game's editor interface.
    Please login to see this link.

    Thanks for helping.

    Working as fast as I can on Fusion 3

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!