Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Joey, flink, AndrewAMD, ozgur, Ayumi), 1,195 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Throwing balls using the physics #298944
11/19/09 15:28
11/19/09 15:28
Joined: Feb 2009
Posts: 38
Germany
P
Phonech Offline OP
Newbie
Phonech  Offline OP
Newbie
P

Joined: Feb 2009
Posts: 38
Germany
Hi there! I would like my player to ent_create balls and throw them by using the physics. The balls are supposed to fly different widths depending on how long the mouse_left was pressed.

That's what I have...

Code:
var save_power;
var ball_power;
var ball_fired;
#define ball_speed skill34

function move_balls();

function handle_balls() //in the player's while(1) loop
{
	if(!mouse_left) ball_fired = 1;
	while(mouse_left)
	{	
		ball_fired = 0;
		if(ball_power < 100)
		{	
			ball_power += 0.1 * time_step;
			save_power = ball_power; //save the value temporary 
		}
		wait(1);
	}	
	if(!ball_fired)
	{
		VECTOR ball_pos[3];
		vec_for_vertex(ball_pos,player,60);
		ent_create("ball.mdl",ball_pos,move_balls); 
		ball_fired = 1;
	}
	ball_power = 0;
}

function move_balls()
{
	my.ball_speed = save_power;
	
	phent_settype(my, PH_RIGID, PH_SPHERE);
	phent_setmass(my, 0.2, PH_SPHERE);
	phent_setfriction(my, 30);
	phent_setelasticity(my, 30, 100);
	phent_setdamping(my, 30, 5);
	ph_setgravity(vector(0, 0, -386));	

	phent_addvelcentral(my,vector(my.ball_speed,0,0));
}



...but it doesn't work. Thanks for your advice!

Re: Throwing balls using the physics [Re: Phonech] #299555
11/24/09 21:06
11/24/09 21:06
Joined: Nov 2002
Posts: 913
Berlin, Germany
S
SchokoKeks Offline
User
SchokoKeks  Offline
User
S

Joined: Nov 2002
Posts: 913
Berlin, Germany
you need to enable the physics engine for that entity before adding forces (addvelcentral)
There are two ways to do it:

phent_enable (ENTITY* entity, var enable); (easier way)

or

phent_setgroup ( ENTITY* entity, var groupID );
and then
ph_selectgroup ( var bitmask );

EDIT: ach ja: die leute können dir besser helfen, wenn du noch dazuschreibst was passiert und was nicht passiert.


Gamestudio download | chip programmers | 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