Author Topic: Crash due to projectile bounce in ::onCollision()  (Read 606 times)

There should be a 25% change someProjectile will bounce when it hits something, otherwise it will stick there until the end of its lifetime, then explode.
Code: [Select]
function someProjectile::onCollision(%this, %obj, %col, %a, %b, %c, %d) {
if(!getRandom(0, 3))
%obj.bounce();
else
parent::onCollision(%this, %obj, %col, %a, %b, %c, %d);
}
For some reason, the engine crashes when this function is called.

I suspect this is a stupidly simple problem with my use of ::bounce(), however I am unable to find out exactly what the problem is.

Could somebody please put me on the right track to fixing this.

A: Why aren't you using the normal bounce mechanism
B: Bounce needs an argument, 1 is probably what you're looking for

Projectile::bounce only seems to work when it hits a brick, otherwise the projectile does weird things like crash or teleport to (0, 0, 0)

A: Why aren't you using the normal bounce mechanism
Because this is not supposed to be random, not dependent on the angle at which the projectile collides with a surface.

B: Bounce needs an argument, 1 is probably what you're looking for
Still crashes.

Projectile::bounce only seems to work when it hits a brick, otherwise the projectile does weird things like crash or teleport to (0, 0, 0)
Is this perhaps because it was written to be called by events?

It looks like I'll be writing my own bounce method.