Modding Help Need Help With Mech Collisions

Discussion in 'Starbound Modding' started by HeroIcarus, Dec 28, 2013.

  1. HeroIcarus

    HeroIcarus Void-Bound Voyager

    I'm creating a custom mech, and have tweaked the collisions and sprite of the standard mech to match what I need.
    However, I cannot make heads or tails of how exactly the lines of code related to collisions actually works.
    Up/down collisions work, as do driving the mech forward into a wall. But when I drive backwards, it collides with walls much too early- as if it's leaving a whole mech-sized space between the mech and the wall for flipping's sake.
    ...Which is the other problem I'm having. When I turn, the mech flips along the axis of the character, not in the center of the sprite. Is there some way for me to make it flip along a certain point?

    Anyway, here's some pictures of the problem I'm having.

    Point of collision driving forward:
    [​IMG]
    Point of collision driving backward:
    [​IMG]

    And here's my current collisions code:
    Code:
    "mechCustomMovementParameters" : {
        "standingPoly" : [ [-3.1, 0.25], [-2, -2.25], [2, -2.25], [3.1, 0.25], [3.1, 0.5], [2, 0.5], [-2, 0.5], [-0.5, 0.5] ],
    I hope you can help me resolve this problem, it's been bugging me for ages!
     
    TohKlidan likes this.
  2. krail

    krail Void-Bound Voyager

    Look at the humanmech collision code to figure it out:
    Code:
    "standingPoly" : [ [-3.5, -2.0], [-2, -4.5], [2, -4.5], [3.5, -2.0], [3.5, 2], [2, 3], [-2, 3], [-3.5, 2] ]
    Each pair of numbers in the "standingPoly" vector is a point in 2d space. Here's a quick visualisation:
    [​IMG]

    Hopefully that should show you how to adjust those points to make the collision poly fit better.
     
    TohKlidan and Nightmares like this.
  3. HeroIcarus

    HeroIcarus Void-Bound Voyager

    I had worked that out myself previously, however it would appear that with the default code, the mech keeps the same collision model even when it flips. I realised that the mech flips along its axis based on the sprite position, and adjusted the sprites and collision model appropriately. It works fine now.

    Did you use a particular program to draw up that visualisation? That could be really useful for me next time I'm editing collisions at 5am and the numbers aren't making and sense.

    Thanks!
     
  4. Heliostorm

    Heliostorm Phantasmal Quasar

    Looks like some kind of alien Segway :p
     
  5. ColonolNutty

    ColonolNutty Ketchup Robot

    "Here's a quick visualization" -> image is broken :lod:
    For real though, I've been looking for hours for any visualization tool of rectRegion or poly or something that could help show how collisions work visually would help me immensely if anyone knew of one that was still available
     
  6. Nexus Of Chaos

    Nexus Of Chaos Parsec Taste Tester

    /debug
    /boxes
    collision shown. edges of given boxes never intersect. just at most touch
     
  7. ColonolNutty

    ColonolNutty Ketchup Robot

    My god! :catbigeyes: I wish I had known this, you are a godsend. This should really be on the wiki..... if it isn't already
     
  8. Nexus Of Chaos

    Nexus Of Chaos Parsec Taste Tester

    also, boxes are color coded. green objects, red blocks, orange entities, etc

    only problem is debug must be enabled the entire time, or it won't show
     
  9. ColonolNutty

    ColonolNutty Ketchup Robot

    Found out yellow is force regions :)
     

Share This Page