Heya, I'm trying to figure out why a certain bool isn't working right. What I'm trying to do is that if `bounceEnabled` is true (the instance starts as true), the player can bounce, and then it toggles to false permanently. So here's what I'm expecting should work fine; `eutaFollow` is another script, and `eutaCollected` is a boolean that helps count +1 to the score:
void Bounce()
{
objectInRange = dr2dcollider.collisionUp;
if (objectInRange && bounceEnabled)
{
RaycastHit2D hit = new RaycastHit2D();
hit = Physics2D.Raycast(transform.position, Vector2.up, 1.0f, whatIsPartial);
if (hit.collider != null && hit.collider.tag == "Player")
{
hit.collider.gameObject.transform.GetComponent().Bounce();
Physics2D.IgnoreCollision(playerPrefab.GetComponent(), GetComponent());
//References another script so that the object follows the player.
eutaFollow.followTarget = hit.collider.gameObject.transform;
eutaFollow.LateUpdate();
bounceEnabled = false;
eutaCollected = true;
}
}
}
So it seems like that should work fine, but instead the function is never called with the bool in there. If `bounceEnabled` is taken out, the player can bounce on the object at any time even when `bounceEnabled` is false.
The other issue I can't figure out is that IgnoreCollision doesn't work, and I've been working with it for a few hours and still can't figure out why. :/ Any help is appreciated. Thank you.
↧