Announcement

Collapse
No announcement yet.

Help! My boat need either trig or physics to work!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help! My boat need either trig or physics to work!

    Here I am again, with a new iteration of an almost working boat. So, I'm running into an issue with getting the suspension on my boat to work. Currently, I am having 4 linetraces trace down from above the boat to just below it. These linetraces are about where wheels would be, and where they hit, I want the boat to have that be its resting height. I have 4 dummy objects having their location set to the hit of the traces. That part works. I have two ideas of how I might get the suspension to work:

    First: Connect the 4 dummy objects to the root (boat) object with 4 physics constraints. The constraints would be set so all axis would be locked but z, and theoretically, that should provide suspension.

    Second: Do some trigonometry math (which I don't know) and find the center point (vector and roatation, forward and up vector, etc) of the 4 hit locations and just have 1 dummy object and physics constraints. I don't think a spring arm would work because it just takes distance from target point into account, rather than momentum (which is what I want).

    My issue is this: I currently have my boat setup with the first idea. However, that just results in my boat spinning end over end and flying off into the distance. I have been told that physics doesn't play nicely when you change the location of things. Is there a way around this? Is there an alternative? I am really beginning to run out of ideas on how to get this darn boat working without some divine (Epic) intervention. T_T

    #2
    Trigonometry won't help you, because four points are generally not all co-planar.
    The physics constraints are a fine way.
    You can also calculate "average tilt" by calculating:
    tilt-left = ((FR-FL)+(RR-RL))/2
    tilt-back = ((FR-RR)+(FL-RL))/2
    This is assuming "FR" is height of front-right cast; "RL" is height of rear-left cast, and so on.
    Now, construct two vectors that consist of the Right-vector plus the up-vector times (tilt-left divided by width), and the Front-vector plus the up-vector times (tilt-back divided by length)
    Normalize those vectors, and construct the "up" vector using cross product.
    This is the orientation of your boat!

    Comment


      #3
      Wow jwatte, that looks like it would really help. Kinda wish I understood more than just the first two tilt-left tilt-back equation parts (if I am correct in my understanding of them at all. when you say height, you mean the world z, yea?). I only know a bit of algebra and geometry, and even that was years ago. Are the tilt-left and tilt-back equations giving parts of rotations?

      I tried putting together what you said, but I am not sure if I got it right, and there are some parts I have questions about. First, am I correct in assuming that tilt-left is roll and tilt-back is pitch and did I implement that correctly? Second, when you say width and length, do you mean the current width and length between the wheels at that moment, or at resting point (I have the dummy objects set to rest at a specific location if the traces don't hit anything). If it is the width and length at that moment, would i get that from subtracting, for example, the vectors of FR and FL and using vector length? Third, after the cross product, is that what you mean buy constructing the up vector? Is that vector (the result of the cross product) the center of my boat? With its rotation?

      Finally, you say physics constraints are a fine way. With this, hopefully I will only have to use one physics constraint, but does that mean it will work fine even with the location being changed each tick? What i was planning was having a dummy object be placed at the center point, have a physics constraint linking the dummy object and the root (boat), and having the physics constraint let the boat move along its z axis. Would this all work, or will issues still crop up from changing location?

      Click image for larger version

Name:	OrientationEquationMaybe.jpg
Views:	1
Size:	454.9 KB
ID:	1087046

      Comment


        #4
        So, instead of "make rot" you could use "make vector."
        Divide the "tilt" amount by the distance between the two measurements (width, and height)
        Then make a vector where x/y comes from the rotation of the boat, and z comes from the "tilt" value.
        Then normalize that vector.
        When you have "right" and a "forward" vector, you can then construct "up" using cross between "right" and "forward"
        And, once you have right/forward/up, you can just plug those as the three columns of a rotation matrix.

        If that still doesn't make sense, I guess a bit of 3D math would be helpful :-) I don't know which tutorials are best these days, but perhaps something like http://chortle.ccsu.edu/vectorlessons/vectorindex.html

        Comment


          #5
          Well now you are just making even less sense. T_T


          So, plug the tilt left into the x of a make vector (since x is forward on my boat), and tilt back into the y of a make vector?

          What do you mean when you say two measurements? Do you mean the two vectors of tilt left and tilt back? So, subtract them from each other and use vector length? So I would divide by the same number for both?

          And then I do a make vector, where x/y come from the root(boat).... what do you mean by rotation? I don't understand how parts of a rotation can successfully make a vector. And what happened to adding and multiplying the forward, right, and up vectors?

          I'm sorry I'm not able to grasp what you are saying more clearly, but the only parts that I get what you are saying is when you are talking about blueprint specific stuff. While I appreciate you directing me to a 3D math tutorial, I'm afraid it won't do me much good. When I was just learning algebra, I failed the class 3 times before I finally managed to pass. I'm really, really bad at math, can't really visualize it at all except, occasionally, when it comes to blueprints. This isn't one of those occasions. Would it be too much to ask for a screenshot?

          Comment

          Working...
          X