Live Chat

The Broadside Express - Continued

Anything related to Wolfire Games and/or its products

Re: The Broadside Express - Continued

Postby mostley » Fri Feb 24, 2012 5:12 am

mostley
 
Posts: 3
Joined: Sat Oct 25, 2008 2:56 am

Re: The Broadside Express - Continued

Postby Korban3 » Fri Feb 24, 2012 6:14 pm

Oh shit, those are both exactly what I needed :lol: You guys are awesome. Now could I just drop contacts into an Array and use a for loop to cycle through it like
Code: Select all
for([Not sure what to put here] in [array] contacts) {
     if (Under characters feet) {
          on_ground = true;
     } else {
          on_ground = false;
     }
}

this or is there a different syntax for that?
User avatar
Korban3
 
Posts: 4146
Joined: Tue May 31, 2011 9:14 pm
Location: 42nd St E, Hell

Re: The Broadside Express - Continued

Postby SamW » Sat Feb 25, 2012 12:44 am

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.

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;
}


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.
SamW
 
Posts: 110
Joined: Fri Jan 15, 2010 3:08 am

Re: The Broadside Express - Continued

Postby confused » Mon Feb 27, 2012 11:32 pm

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.
confused
 
Posts: 53
Joined: Mon Sep 19, 2011 6:12 pm

Re: The Broadside Express - Continued

Postby Korban3 » Tue Feb 28, 2012 12:13 am

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.
User avatar
Korban3
 
Posts: 4146
Joined: Tue May 31, 2011 9:14 pm
Location: 42nd St E, Hell

Re: The Broadside Express - Continued

Postby moopdog » Thu May 24, 2012 7:34 pm

Image
moopdog
 
Posts: 1
Joined: Wed Feb 29, 2012 12:36 am

Re: The Broadside Express - Continued

Postby Jacktheawesome » Fri May 25, 2012 12:12 am

Willis, you wear that goddam tophat with pride.
User avatar
Jacktheawesome
 
Posts: 2406
Joined: Sun Sep 12, 2010 1:06 am
Location: In Zulway's foot palace.

Re: The Broadside Express - Continued

Postby Zeltrax » Mon Oct 22, 2012 1:29 pm

Is this continuation of this project dead? If not that would be awesome! :)
Zeltrax
 
Posts: 3
Joined: Mon Dec 05, 2011 1:41 pm

Re: The Broadside Express - Continued

Postby Korban3 » Mon Oct 22, 2012 4:08 pm

Yeah, it's fairly dead. I don't even run an OS that Unity supports anymore.
User avatar
Korban3
 
Posts: 4146
Joined: Tue May 31, 2011 9:14 pm
Location: 42nd St E, Hell

Previous

Return to Wolfire

Who is online

Users browsing this forum: Bing [Bot] and 5 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group