Advertisement

How do i find out the width of my model?

Started by February 17, 2005 01:38 PM
11 comments, last by BangorRipper 20 years ago
Try something like this:

(Use "OR" instead of "AND")
(Make the conditions "<=" or ">=" instead of just "<" or ">")
if((bullet[0].xBullet >= aliens[x].xAlien - 2.0f) | (bullet[0].zBullet >= aliens[x].zAlien - 2.0f)){    if((bullet[0].xBullet <= aliens[x].xAlien + 2.0f) | (bullet[0].zBullet <= aliens[x].zAlien + 2.0f))    {        //--Collision        System.out.println("hit alien no. " + x);    }}//--No Collision


I'm at work right now so i have no references and I'm did it out of my head, but I will help as much as I can.
The code you sent didnt work but i have now improved mine and it seems to work fine now, code is below:

if(bullet[0].xBullet - 0.2f <= aliens[x].xAlien + 1.367632f &&
bullet[0].xBullet + 0.2f >= aliens[x].xAlien - 2.222750f)
if(bullet[0].zBullet - 0.5f <= aliens[x].zAlien + 1.116205f &&
bullet[0].zBullet + 0.5f >= aliens[x].zAlien - 0.931442f)
{
System.out.println("hit alien no. " + x);
aliens[x].alienDead(true);
}
Advertisement
code doesn't work v.well, actually its cr*p, one shot kills more than one alien, really cant spot it,
here is my current code:

for(int x = 0; x < aliens.length; x++)
{
if((aliens[x].xAlien >= (bullet[0].xBullet - 0.2f)) && (aliens[x].xAlien <= (bullet[0].xBullet + 0.2f))&& (aliens[x].zAlien >= (bullet[0].zBullet - 0.5f)) && (aliens[x].zAlien <= (bullet[0].zBullet + 0.5f)))
{
System.out.println("hit alien no. " + x);
i'm sure my aliens are getting plotted at 0,0 but obviously translated, so all i should need to do is work out within its width!! :(

This topic is closed to new replies.

Advertisement