XNA Creators Club Online
Page 1 of 1 (8 items)
Sort Posts: Previous Next

collision error

Last post 11/11/2008 4:11 AM by Jaeyoon. 7 replies.
  • 11/8/2008 10:03 PM

    collision error

    Im trying to get my icicles to fall when they get hit by a projectile. I have the icicles in an array. They are loaded across the top of the screen and i have the firing code going fine for my projectiles. But when the projectiles hit the icicles on the top of the screen, the projectiles die but the icicles dont fall.. Help plz.
    here is my code: http://rafb.net/p/KhCm1s17.html
  • 11/8/2008 10:26 PM In reply to

    Re: collision error

    Do you update the position of the icicle anywhere else?  Because it looks to me like you update it only for the one frame when it is colliding with the ball (and the velocity is still 0)
    Regards,
    Louis Ingenthron
    Fortis Venaliter
    Lead Developer of FV ProductionsFV Productions
  • 11/9/2008 1:53 AM In reply to

    Re: collision error

    this is the only other code that affects icicleroof:

    http://rafb.net/p/wctOuA35.html

    I set the velocity in the update icicle method with the line:
    icicle.velocity = new Vector2(0, (float)icicle.position.Y - 1.0f) * 2.0f;
  • 11/9/2008 2:00 AM In reply to

    Re: collision error

    Yep, but just setting the velocity won't do anything. Somewhere, you need to do
    icicle.position += icicle.velocity;
    every frame. Or, better yet,
    icicle.position += icicle.velocity * (float)gameTime.ElapsedGameTime.TotalSeconds;
    Regards,
    Louis Ingenthron
    Fortis Venaliter
    Lead Developer of FV ProductionsFV Productions
  • 11/9/2008 4:50 AM In reply to

    Re: collision error

    line 57 in the first link that i gave has the code: icicle.position += icicle.velocity; /? that statement is held in the updateProjectile method. I have updateProjectile; in the update method. So I dont understand why its not working. Will adding the gametime line make it work?
  • 11/9/2008 8:11 AM In reply to

    Re: collision error

    Because, if I read it right, it will only update the icicle velocity for the one frame that it is collided with a projectile.
    Regards,
    Louis Ingenthron
    Fortis Venaliter
    Lead Developer of FV ProductionsFV Productions
  • 11/9/2008 4:36 PM In reply to

    Re: collision error

    So then in order to fix that should i just put the icicle.position += icicle.velocity; directly into the update method instead of a separate method that is called by the update method?
  • 11/11/2008 4:11 AM In reply to

    Re: collision error

    Ok so here is what i tried:
    I put the statement:
    foreach( gameobject icicle in icicles)
    {
    if (icicle.hit)
    {
    icicle.position += icicle.velocity;
    }
    }

    and its still not working. I thought the update method does this statement during each frame so then i dont understand how it could be adding it for only the one frame that the projectile collides with the icicle.
Page 1 of 1 (8 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG