- Home /
isKinematic = false makes unity executable crash
So here's the thing. I'm making a destructible house that when you click on parts of it, chunks get removed and fly around. It works perfectly in the editor, it flys around and looks a bit like Age of Empire 3 (which is GOOD).
Problem is, every piece is set to isKinematic = true at startup and I give the isKinematic = false with a script to unlodge them and make them fly around. Like I said, in the editor it works, but the second I do that in an executable BAM it crashes and gives me this pretty little log :
Unity Player [version: Unity 4.3.0f4_e01000627d60]
GoC2.exe caused an Access Violation (0xc0000005)
in module GoC2.exe at 0033:80509e3c.
Error occurred at 2013-11-30_143026.
D:\Projets\God of Chaos 2\Exec\GoC2.exe, run by Fel.
20% memory in use.
16282 MB physical memory [12882 MB free].
18714 MB paging file [14299 MB free].
134217728 MB user address space [134217323 MB free].
Read from location ffffffff caused an access violation.
Context:
RDI: 0x02916520 RSI: 0x00000000 RAX: 0x00000002
RBX: 0x0f3247a8 RCX: 0x00000006 RDX: 0x00000009
RIP: 0x80509e3c RBP: 0x00000000 SegCs: 0x00000033
EFlags: 0x00010202 RSP: 0x00adefc0 SegSs: 0x0000002b
R8: 0x00000003 R9: 0x029318dc R10: 0xe0000000
R11: 0x00adef80 R12: 0x00000008 R13: 0x00000000
R14: 0x02a0e718 R15: 0x029c7460
Bytes at CS:EIP:
0f 54 8c 24 88 01 00 00 44 0f 54 9c 24 88 01 00 Module 1
C:\WINDOWS\SYSTEM32\xinput1_3.dll
Image Base: 0x00400000 Image Size: 0x0001e000
File Size: 107368 File Time: 2007-04-04_185422
Version:
Company: Microsoft Corporation
Product: Microsoft® DirectX for Windows®
FileDesc: Microsoft Common Controller API
FileVer: 9.18.944.0
ProdVer: 9.18.944.0
== [end of error.log] ==
So, I have Unity free and no plugins whatsoever, just pure javascript and 3ds max models with textures and a terrain. When I remove that kinematic line from my code it works in the executable but well, the chunks don't get removed which is pretty dumb and not what I want at all.
Should I file an error report directly to Unity or am I doing something wrong here?
Answer by davedev · Dec 02, 2013 at 08:27 PM
I don't know enough to help specifically, but I'd find exactly where in your code the application crashes. For example, is it when when game object load, get drawn to the screen, when the code hits one of your kinematic objects, or when it hits something related to your objects. If you find that you might be able to program around it or it might give more info for resolving rather than the error log.
Its exactly the line with "is$$anonymous$$inematic = false" that crashes. Precisely that line.
var radius = 5.0;
var power = 10.0;
function Start () {
// Applies an explosion force to all nearby rigidbodies
var explosionPos : Vector3 = transform.position;
var colliders : Collider[] = Physics.OverlapSphere (explosionPos, radius);
var colliders$$anonymous$$inematic : Collider[] = Physics.OverlapSphere (explosionPos, radius/8);
for (var hit : Collider in colliders$$anonymous$$inematic) {
if (hit && hit.rigidbody){
hit.rigidbody.is$$anonymous$$inematic = false; // RIGHT HERE
}
}
for (var hit : Collider in colliders) {
if (hit && hit.rigidbody){
hit.rigidbody.AddExplosionForce(power, explosionPos, radius, 3.0);
}
}
}
Ah ok. Like I said, I've never encountered this specifically. Why are you disabling the physics? What you've done seems like it should work in theory, but in several physics engines I've had issues with turning physics on and off so usually I have either two copies of the object for things like allowing user dragging AND physics or I coerce physics into doing what I want such as using force to achieve what I want to do by turning physics off.
Well what I have is a house with frozen chunks (Physics disabled). When an explosion is set upon the house, the physics of chunks around a certain radius of the explosion are turned on and then applied a force to send them flying. Like I said, it works fine in the editor. But in the executable it just gives me that annoying Access Violation. I tried disabling them in another way, like constraining them while leaving the physics on but it starts lagging terribly.
Just some thoughts. You might want to move your code to a FixedUpdate handler ins$$anonymous$$d of Start. Physics behaviors work better in fixed update and sometimes hicky things can happen in Start functions/first frame like from not everything being really initialized.
The other thing you could do is build your house with non-rigidboy chunks and then swap them at explosion time with rigid body versions using moveTo and then explode away.
Answer by niall1111 · Sep 17, 2014 at 06:53 PM
That's quite an old version of Unity, why not upgrade to the latest (4.5.3 I believe) and see if that fixes your problem? There's a good chance that if this is a bug, it's been fixed in the dozens of versions between yours and the current one. :)
Quite an old version of Unity, because it's quite an old question...