2 Questions about pinball like stuff.

Posted By: Ready

2 Questions about pinball like stuff. - 12/24/07 21:45

Ok, I'm currently working on some things frequently seen in pinball games
First, a bouncer (like, on touch it bounces you(phent ball) away.
Right now, the bouncer entity (a sphere, placeholder) rotates so that its facing the player on impact but I just cant get the actual push to work correctly >_<
Code:
 function event_bounce() 
{
if (event_type == EVENT_IMPACT )
{
vec_set(temp,player.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp);

phent_clearvelocity(player);
// this part isnt working right :((
//phent_addvelcentral (player,my.pan ); //schieben
phent_addvelcentral (player, vector(my.pan, 0, 0)); //schieben

return;
}
}


I messed with that for quite some time and I can somehow get it to bounce the player away but the direction it pushes the player to is always [censored] up and never quite right


So now for my second problem
I want to make a function/event that, when the player collides with another phent (another ball in this case) creates a force at the exact impact location so it pushes both balls away. I was thinking about scanning for the nearest vertex where the impact happened but I have no real idea how exactly I should do this :s

Any kind of help or hint would be appreciated

Merry Xmas
- Ready
Posted By: xXxGuitar511

Re: 2 Questions about pinball like stuff. - 12/24/07 22:42

y don't u just attach a constraint to the bumper and use the physics functions for adding torque.
Posted By: Ready

Re: 2 Questions about pinball like stuff. - 12/24/07 23:16

aren't constraints only used to limit the degree of freedom for an object (like, an arm cannot rotate 360° in all directions)
Sorry I'm a poor artist who's new to programming ^^
Posted By: xXxGuitar511

Re: 2 Questions about pinball like stuff. - 12/24/07 23:26

..Sorta, yeah. If you added a hinge constraint to the bumper, then it could only rotate along the z axis.
Posted By: Ready

Re: 2 Questions about pinball like stuff. - 12/24/07 23:36

Hmm, that wouldn't solve my problem I think.

Rotating the bumper to face the player isn't the problem, but to add a force to the player along the bumpers pan axis

..so .. confusing...
Posted By: xXxGuitar511

Re: 2 Questions about pinball like stuff. - 12/25/07 02:45

...Thats what using physics does. The force unto the player is done by the physics engine
Posted By: Ready

Re: 2 Questions about pinball like stuff. - 12/25/07 03:41

duh.. off course
My problem with the bumper is "just" applying either velocity or torque (or both) to the player into the direction of the bumpers pan

While writing this, I had another idea and quickly tested it out
if I use

phent_addvelcentral (player, vec_scale(my.pan, 50));

it seems to work more or less. for some reason it only bounces the player away in 3 of 4 impacts

Got no real ideas yet about the two colliding balls problem though.
© 2024 lite-C Forums