The Broadside Express - Continued
Re: The Broadside Express - Continued
Oh shit, those are both exactly what I needed You guys are awesome. Now could I just drop contacts into an Array and use a for loop to cycle through it like
this or is there a different syntax for that?
Code: Select all
for([Not sure what to put here] in [array] contacts) {
if (Under characters feet) {
on_ground = true;
} else {
on_ground = false;
}
}
Re: The Broadside Express - Continued
One thing is I think the OnCollisionEnter/Stay/Exit is called separately for each collider colliding with the object. Your example sets the on_ground for whatever the last contact point for whatever OnCollisionStay collider is called last. I think something like this is more suitable.
I think that is proper javascript...
Not sure if an objects Update function can be called between the FixedUpdate and the OnCollisionStay callbacks, so I would be careful where I used the on_ground_fu variable in this sample. I would probably stick with using it in the fixed update function. If you want to use the variable in the regular update or anywhere else then I would maintain a separate variable like I did above.
You actually don't need to use shperecheck for what you want, you can probably just check the contact point's elevation (y value) to see if it is by the feet.
Code: Select all
class sampleClass extends MonoBehavior
{
var on_ground_fu = false;
var on_ground = false;
function FixedUpdate()
{
//Anything else here
on_ground = on_ground_fu;
on_ground_fu = false; //Reset it to false so we can check again next FixedUpdate.
}
function OnCollisionStay( var collision : Collision)
{
for( var contact : ContactPoint in collision .contacts)
on_ground_fu = on_ground_fu || spherecheck(foot_position, foot_size, contact.point);
}
}
//------------------------------------------------------------------------
function spherecheck(var sphere_center : Vector3, var shpere_radius : float, var point : Vector3)
{
if( (point-sphere_center).sqrMagnitude < sphere_radius*shpere_radius)
return true;
return false;
}
Not sure if an objects Update function can be called between the FixedUpdate and the OnCollisionStay callbacks, so I would be careful where I used the on_ground_fu variable in this sample. I would probably stick with using it in the fixed update function. If you want to use the variable in the regular update or anywhere else then I would maintain a separate variable like I did above.
You actually don't need to use shperecheck for what you want, you can probably just check the contact point's elevation (y value) to see if it is by the feet.
Re: The Broadside Express - Continued
I just found out that the nice cg/blender cookie guys also made a http://unitycookie.com and it looks like an equally great resource.
Also i saw that there was a lincense linked from github, but i could not find a the broadside express on github, is it up there ? If not it would be great if you could drop your current code there Korban. That way everyone can easily contribute, or fork to test their own ideas and re-merge later if it turns out to be good. Of course it would also help the project to stay alive even if you decide to move on.
Also i saw that there was a lincense linked from github, but i could not find a the broadside express on github, is it up there ? If not it would be great if you could drop your current code there Korban. That way everyone can easily contribute, or fork to test their own ideas and re-merge later if it turns out to be good. Of course it would also help the project to stay alive even if you decide to move on.
Re: The Broadside Express - Continued
Hm, I haven't seen it in there. Maybe it's just tucked away somewhere. If I make any more progress I'll be sure to drop the source there. As is, I haven't made progress since I got the buggy to work. And that's really about all I got done anyways. I've had school stuff on my mind, mostly graduation stuff Hopefully, this stuff clears up soon and some time frees up. Otherwise, I'll probably have to wait a rather long while for some freetime for projects. Probably.
-
- Posts: 2406
- Joined: Sun Sep 12, 2010 1:06 am
- Location: In Zulway's foot palace.
- Contact:
Re: The Broadside Express - Continued
Willis, you wear that goddam tophat with pride.
Re: The Broadside Express - Continued
Is this continuation of this project dead? If not that would be awesome!
Re: The Broadside Express - Continued
Yeah, it's fairly dead. I don't even run an OS that Unity supports anymore.