Destroyable Projectile

Topics regarding Scripting with Reality Factory
Post Reply
Veleran
Posts: 891
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Destroyable Projectile

Post by Veleran » Fri Feb 26, 2010 11:00 pm

If you want a projectile to be destroyable like in the old coin -op : Karnov
where a rock appears on the hands of an enemy and then it is hurled towards the player,bounce at the ground for some seconds and fade- or explode
but you can shoot it,does it need to be a pawn?

I wonder how will make the rock pawn to bounce.If no one has an idea,and i wont manage it,then i will use projectile even if it wont be destroyable,unless the projectiles are updated to have health.

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Destroyable Projectile

Post by metal_head » Sun Mar 07, 2010 3:05 pm

It's possible to make a pawn bounce, at the moment i'm working on a project where I'm trying to imitate physics with scripts and I'm actually good at it :D

So for bouncing:
You'll need a variable, that stores the last Y position and another one, that stores the amount of Y the pawn has fallen during the last check. So it will be something like:

Code: Select all

if((self.current_Y < last_y) and self.IsFalling)  //checks if the pawn is in the air and it's falling down
{
force_amount = last_y - self.current_Y; 
} 
So now you have the speed, that the pawn goes down with. Now for the bouncing you can use that speed, multiplied by something, and apply it in a ForceUp() command.
So now I think it would be best to do this:

Code: Select all

if((force_amount > 0) and (self.IsFalling = false)) //if the pawn is no longer in air and there's a falling speed
{
ForceUp(force_amount*2);
force_amount = 0;
}
Often the things I do don't work from the first time, so try this and tell me if it works. :)

Also: you might ask why multiplying. Well, force_amount would be a really small value, 'cuz that's the amount of texels the pawn travels PER FRAME, and unless it's falling freakin' fast, it won't give a big value.

Post Reply