Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,435 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Adding force when a ball collides with anything... #36695
11/23/04 05:01
11/23/04 05:01
Joined: May 2003
Posts: 114
Scotland
N
Negioni Offline OP
Member
Negioni  Offline OP
Member
N

Joined: May 2003
Posts: 114
Scotland
I'm having a problem....i have a ball which iv got behaving as such, so it collides with walls/models/pink elephants and bounces....great....but i need it to gain speed when it collides with anything. iv been trying for the last couple of hours and i cant get the phent_addforceglobal etc to work. i used the code in aum25 as a starter but to save anybody time, heres the code.

Code:
 
function create_ball()
{
if ((balls < 1) || (ball_ptr != null)) {return;} // ran out of balls -> stop
ball_ptr = ent_create(ball_mdl, ball_pos, init_sphere);
balls -= 1;
}


function init_sphere()
{
phent_settype(my, ph_rigid, ph_sphere); // enable physics for this ball
phent_setmass(my, 100, ph_sphere); // the ball has 1kg (2 lbs) and behaves like a sphere
phent_setfriction(my, 0); // friction
phent_setelasticity(my, 100, 0); // bounce a lot
temp.x = 0;
temp.y = -250;
temp.z = 0; // earth gravity factor, g = 9.81 m/s2
ph_SetGravity(temp); // set gravity
while (my.z > -150) {wait (1);} // the ball has approached the floor
if (EVENT_TYPE == Event_impact)
{
temp2.x = 0;temp2.y-=100;temp2.z=0;
ph_setgravity(temp);
}
wait(1);
}



any help would be mega appreciated.

Negioni.


Omniworld: Descendants of Power - Team members required for Fantasy FPS/RPG in progress. E-mail me for more information - all will be considered. http://www.lostgames.uk.tt
Re: Adding force when a ball collides with anything... [Re: Negioni] #36696
11/23/04 23:03
11/23/04 23:03
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline
Expert
A.Russell  Offline
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan

I think it is the way you are calling the event

Code:

function init_sphere()

{
my.enable_impact = on;
my._event = bounce_event;
....
}

function bounce_event()
{
if(event_type == event_impact)
{
//addforce along the BOUNCE vector here or you might want to wait a frame to make sure the ball has already changed course and then just boost it in that direction.
//experiment)
}
}



Re: Adding force when a ball collides with anythin [Re: A.Russell] #36697
11/24/04 06:50
11/24/04 06:50
Joined: Sep 2003
Posts: 3,236
San Diego, CA
M
Marco_Grubert Offline
Expert
Marco_Grubert  Offline
Expert
M

Joined: Sep 2003
Posts: 3,236
San Diego, CA
Almost right, but physics collisions are EVENT_FRICTION.

Code:
function init_sphere()

{
phent_settype(my, ph_rigid, ph_sphere); // enable physics for this ball
phent_setmass(my, 100, ph_sphere); // the ball has 1kg (2 lbs) and behaves like a sphere
phent_setfriction(my, 0); // friction
phent_setelasticity(my, 100, 0); // bounce a lot
temp.x = 0;
temp.y = -250;
temp.z = 0; // earth gravity factor, g = 9.81 m/s2
ph_SetGravity(temp); // set gravity
my.enable_friction = on;
my._event = bounce_event;
}

function bounce_event()
{
if(event_type == event_friction)
{
//phent_addglobalforce here
}
}




Moderated by  HeelX, Spirit 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1