Jump to content

Mesh collider is correct but incorrect


Recommended Posts

#####SOLVED#####

This problem is nearly game-breaking (it's certainly stopped me from continuing my mod project), and it has absolutely no reason to exist.

I made a video showcasing the problem, but it appears my recording software is spitting out unusable video files.

My problem is that the Center of Mass is WAY of in the VAB. As in, the center of mass is on the edge of the model. And it's not the mesh, because I can hover my mouse over the ghost space where objects attach radially (they act like there are two collision meshes, one in this weird area and one where I put mine) and not select anything. The model has a tendency to fall over on the launchpad, thus proving that the problem is not an extra mesh (it wouldn't have fallen over; the mesh should support it). Below is the config, although I doubt it's something there.


PART
{
// Kerbal Space Program - Part Config
// F500 Fuel Tank
//

// --- general parameters ---
name = f500FuelTank
module = Part
author = BlazerNitrox

// --- assets parameters ---
mesh = f500FuelTank.mu
rescaleFactor = 1.25

// --- node definitions ---
node_stack_top = -0.7, 2.0, -0.7, 0.0, 1.0, 0.0, 1
node_stack_bottom = -0.7, -2.0, -0.7, 0.0, 1.0, 0.0, 1
node_attach = 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1

// --- editor parameters ---
TechRequired = advRocketry
entryCost = 0
cost = 2000
category = FuelTank
subcategory = 0
title = F500 Fuel Tank
manufacturer = Blazer Rocket Industries
description = After everyone getting upset about how "heavy" the fuel tanks are, Blazer Rocket Industries decided to build this tank, which has plastic walls. Of course, then everyone was worried that it was too easy to destroy, so they put reinforcements on it, making it heavier.

// attachment rules: stack, srfAttach, allowStack, allowSrfAttach, allowCollision
attachRules = 1,1,1,1,0

// --- standard part parameters ---
mass = 0.5
dragModelType = default
maximum_drag = 0.2
minimum_drag = 0.3
angularDrag = 2
crashTolerance = 12
breakingForce = 50
breakingTorque = 50
maxTemp = 1500

RESOURCE
{
name = LiquidFuel
amount = 720
maxAmount = 720
}

RESOURCE
{
name = Oxidizer
amount = 880
maxAmount = 880
}
}

Edited by Blazer Nitrox
Link to comment
Share on other sites

the config file is fine.

problem lies with the mesh's pivot. make sure the pivot for the visible mesh and collision mesh are in the same location, and have same rotation. the part's center of mass is the pivot of the object with Part Tools script. if you use an empty game object for the Part Tools script, place that object at the CoM of your part before export. multiple mouse over areas is probably due to having multiple collision meshes that are not aligned. resetting the pivots to the part's CoM should solve that.

Link to comment
Share on other sites

And it's not the mesh, because I can hover my mouse over the ghost space where objects attach radially (they act like there are two collision meshes, one in this weird area and one where I put mine) and not select anything.

this certainly reads like there are multiple areas responding to a mouse over.

at any rate. you used capsule collider, it has rounded ends, of course it will tip over...

looking at this, https://i.imgur.com/SDXMVrc.png, your collider is off-center relative to the visible mesh.

set your pivot display to "Pivot" & "Local"

set your GameObject to 0,0,0 position and rotation

rotate your visible mesh so it is positioned at 0,0,0 and oriented correctly. probably 90,0,0

remove "Animator" component

remove and reapply capsule collider. it should automatically size to fit the visible mesh. If it sits horizontally, change "Direction" to Y-Axis, adjust Radius and Height. Center should be 0,0,0

Link to comment
Share on other sites

Your edits definitely moved the center of mass, but it didn't actually make it better (the CoM used to be about a meter to the left; now it's about a meter to the right). Here's the links for the images.

One thing you can't see is that the mesh didn't reorient properly.

Edited by Blazer Nitrox
Link to comment
Share on other sites

Blender calls it "Origin"; Unity calls it "Pivot". your pivot is off center. the pivot is what KSP uses to figure CoM. your pivot is off on the right wall of the tank judging by that picture. The center of your mesh should be aligned to 0,0,0 relative to GameObject. since the pivot is off to one side, you have to correct it by moving "model" by the same distance as the radius of the cylinder in the opposite direction. You may have to move it in all X,Y,Z to position the visible mesh properly. Best way is to fix it in Blender, link down below...

PT5Rezg.jpg

your mesh and pivot on the left; I replicated what you have with a simple cylinder in the middle; the right side is what you want. The capsule collider's direction setting will depend on it's host object's local pivot. The blue and red axis indicates world axis, they intersect at 0,0,0. Since you imported from Blender (my guess), Z is Blender's Up/Down axis, the capsule collider should be set to Z-Axis. In this case you would have to adjust the capsule collider's center to counter correct for the mesh's offset pivot.

Think of it this way...

GameObject with Part Tools script is at 0,0,0, relative to World.

"model"'s position is relative to GameObject, not the World. Since "model"'s pivot is to the side, you have to shift it in the opposite direction by the radius so it's visible center (the Center of Mass you want) is at 0,0,0 relative to GameObject. This will ensure the Center of Mass in game is at the position you would expect for cylindrical object like your fuel tank.

capsule collider inherits it's center from "model", which is off to the side. You shifted "model" earlier, which means capsule collider is now offset by the radius relative to GameObject. So you have to adjust the center setting so the collider is overlapping the "model" properly.

you should fix the pivot in Blender and then import the mesh again. http://wiki.blender.org/index.php/Doc:2.6/Manual/Modeling/Objects

Edited by nli2work
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...