Jump to content

[Solved]Some Collider questions


Recommended Posts

Okay,

So I've spent yesterday and today getting to grips with some of the basics of blender, unity, part tools and getting them all to play together. Thanks to the information on here, I have largely figured it out now, except for one detail. I'll start with what I've done, so you know where I am.

I need to update some models for an existing mod, which was not my own. I have managed to import the .mu files into blender, and export them into .blend, and get those to play together fairly well with unity. The problem arises with one particular model and generating colliders for it.

The model has a high-detail, high polygon count object, and a simple cylindrical collider mesh. It's taken me most of the afternoon to figure out that it kept falling through the launchpad because unity was throwing errors about the polygon count in the high-detail object's (unity-generated Mesh collider) collider being too high. Once I generated another simple collider for that object (another cylinder), and gave both cylinders collider meshes in Unity, and removed the one for the original object, it no longer falls through the launchpad. If I remove either one of the colliders it falls through.

So, that's where I am now. It's basically working, but I'm not sure if I'm doing something wrong. I've tried using a simple cylinder model instead, and that works provided I give it a collision mesh in blender (a total of two cylinders - one for the object and one collision mesh), and give both of these items Mesh Colliders when I import into Unity.

The only problem is, using this method, the edge highlight has stopped working in the VAB. The part can still be selected and moved, but shows no tooltip.

No matter how I try to rearrange the collider hierarchical relationships, if I have anything less than 2 Mesh Colliders it just seems to fall straight through the pad. I must be doing something wrong, right?

Can anyone advise best practice for this kind of thing?

EDIT: Yes, The Mesh Colliders are set to Convex :) Using Unity 4.6.2 and the latest Blender (2.73).

Solved: Attempting to animate a part without an animation may cause collider issues!

Edited by Kielm
Solved
Link to comment
Share on other sites

Having a little trouble figuring out what you're doing, but I'll try and point you in the right direction for best practice..

Adding mesh collider to a visible mesh object and clicking convex is the worst thing you can do. For some objects, it won't even work. Others, as you've found, will go over the 255 poly limit and won't work either. It gives the already over-worked physics engine a hard time too.

The best solution performance wise is to use the primitive colliders added to empty game objects. These can be children of the mesh objects, and this is usually the best way to do it.

If you must use a mesh collider (cone or pyramid sort of shapes are a great example of this), make a dedicate mesh that's as simple as you can and add the mesh collider component (with convex) as you've been doing. To prevent this being visible in game, remove the "Mesh Renderer" component on that object, but NOT the mesh filter.

You'll find that setting collider objects to certain layers stops them being used to select a part in the editor or for the RCM. WheelCollidersIgnore is a great example of this. The collider will still function for collisions, but the mouse will totally ignore it.

Unity 4.2.2 is the best option, as the later versions have animation mechanisms that KSP doesn't support, and you'll struggle with animations. I doubt that's the problem here, though. I suspect you've got some errors in the console in Unity when you click write? Part tools little or no error handling. It will merrily go about its job until it can't, then stop without warning or message unless you're looking at the console, and this can lead to half exported parts.

Link to comment
Share on other sites

Some good advice there, thanks!

I tried adding a single collision mesh as a child object in unity, using one of the primitives available added to a blank game objects. It allows surface attachment on the part in the VAB, but the part will fall through the pad if it's the bottom part, and still doesn't show any tooltip or edge highlighting :\

I'm not getting any errors in Unity since the 255 polygon message much earlier today, it's all just copying textures or cleaning up leaked objects.

- - - Updated - - -

I guess I should summarize my problems, as there are a couple here.

1. The new part falls through the launchpad, but can be selected, moved and right clicked in the VAB

2. The part has no tooltip in the VAB or edge highlighting to show the mouse is over it

3. If I have anything less than two colliders attached to it in Unity it falls through the launch pad.

Link to comment
Share on other sites

Is the collider definitely a child of the game object that part tools is applied to? Very easy for it to look like that's the case, when actually it's just in the scene. It caught somebody making an engine out recently. A definite way to tell is delete the object with part tools applied. What's left in the scene wasn't underneath it in the hierarchy, and won't have been exported. It's showing all the signs of being a plain old missing collider issue.. surface attachment doesn't rely on there being a collider, while selection for moving, rcm and highlighting does.

Link to comment
Share on other sites

I've tried this:

http://imgur.com/XIwTYTf

and this

http://imgur.com/XJ2XDEY

In both cases, collider_base and collider_base_collider both have Mesh Colliders. It only works with both enabled. If I remove either one, it does not.

At this point, I think I may have to try an earlier version of Unity and reinstall Part Tools. :\

Link to comment
Share on other sites

Yea, downgrading won't help a basic problem like that, it is just to help with animations ( and I did read somewhere you can use the new anim system if you rig your model with a single piece skeleton I think? certainly some trick to it ).

Show us a screenshot of the model in unity with the colliders visible in the 3d view?

Link to comment
Share on other sites

Thanks for taking a look. I used a basic box collider from unity instead and that hasn't resolved the problem.

Now I'm starting to think it may be something in the part config. Can you spot anything obviously wrong with this?


PART
{
name = ESLD_LB-10
module = Part
author = EKSTRA Superluminal Logistics Division
MODEL
{
model = ESLDBeacons/Parts/Beacons/LB10
texture = ESLDBeacons/Parts/Beacons/LB10tex
scale = 0.3125, 0.3125, 0.3125
}
rescaleFactor = 1

CrewCapacity = 0

node_stack_bottom = 0.0, -0.375, 0.0, 0.0, 1.0, 0.0, 1
node_stack_top = 0.0, 0.375, 0.0, 0.0, 1.0, 0.0, 1

TechRequired = advElectrics
entryCost = 17800
cost = 110000
category = Utility
subcategory = 0
title = LB-10 "Shortcut" Beacon
manufacturer = EKSTRA Superluminal Logistics Division
description = Developed to simplify in-system transfers, the LB-10 detonates crystalline Karborundum to rip a small hole in space-time. Ships can then (potentially) pass through the breach and (hopefully) emerge (mostly) intact at another beacon. That's the theory, anyway. The LB-10 is optimized for distances of under 1 gigameter, but is okay with a wide range of weights.

attachRules = 1,0,1,1,0

// --- standard part parameters ---
mass = 1
dragModelType = default
maximum_drag = 0.2
minimum_drag = 0.2
angularDrag = 2
crashTolerance = 9
maxTemp = 3400

explosionPotential = 0

vesselType = Station

MODULE
{
name = ModuleEnviroSensor
sensorType = GRAV
}

MODULE
{
name = ESLDBeacon
beaconModel = LB10
}

MODULE
{
name = ModuleAnimateGeneric
animationName = LB10Anim
}

RESOURCE
{
name = ElectricCharge
amount = 100
maxAmount = 100
}

RESOURCE
{
name = Karborundum
amount = 0
maxAmount = 50
}

}

- - - Updated - - -

I have just noticed that Unity is throwing some errors:

typeTree.m_Children.front ().m_Type != SerializeTraits<SInt32>::GetTypeString (NULL)

UnityEditor.DockArea:OnGUI()

Link to comment
Share on other sites

Someone with a bit more experience will have to dig in at this point I think. However it's probably good at this point to go back and do all your final transformations in Blender, so you have a correctly oriented piece+collider in Unity ( and in game ) which doesn't need any scaling. You can also put colliders for visible objects in the same game object as the mesh - provided they don't need translation - if you wanted to simplify your unity tree a little.

Edited by Van Disaster
Link to comment
Share on other sites

Thanks for your help so far.

I've managed to fix the unity errors, which were left over from an earlier installation. After completely removing it and reinstalling 4.2.2 the errors seem to have cleared up.

The problem is still there however, so I'm a bit stumped until I can get this fixed :\

Link to comment
Share on other sites

Bundle it up and send over if you like?

Best way to do that is - in Unity - select your scene, model, material and texture (anything that's related to this part), right click and select Export Package. This will spit out a .unitypackage, which includes all the metadata to link the game objects to the bots of mesh etc. Zip that up, post the link and I'll see what I can do for you.

Should look something like this:

1FQ67e8.png

Link to comment
Share on other sites

Config error. Or animation error, depending how you want to look at it.

There's no animation called LB10, so ModuleAnimateGeneric was throwing an index out of range exception. Diagnostic steps, for future reference:

Always look at the ALT+F2 log if you're having trouble. In this case, an error shows up in red, though it's not very helpful as it doesn't tell you what threw the exception. Output_log in the KSP_Data directory is more verbose and tells you this, though:


IndexOutOfRangeException: Array index is out of range.
at ModuleAnimateGeneric.OnStart (StartState state) [0x00000] in <filename unknown>:0


at Part.ModulesOnStart () [0x00000] in <filename unknown>:0


at Part+.MoveNext () [0x00000] in <filename unknown>:0

This tells you that there's an issue with MAG. Remove it from the config, and everything starts working. If you do want an animation, there are some tutorials in the mod dev links that will run you through how to set it up. Otherwise, it looks fine in Unity. Good luck!

Link to comment
Share on other sites

Insert Scream Here.

I didn't even want an animation - it was left over from the config of the old part I'm replacing. That'll teach me. You're right, everything works absolutely fine without that module!

Well, two days, one lesson learnt :)

Thanks very much for your help lo-fi, I'll make sure to check the logs first in future. Not enough rep in the world for you.

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...