Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, TipmyPip, VoroneTZ, Quad, 1 invisible), 688 guests, and 11 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Physics help needed for controls similar to Half-Life 2 #442306
06/17/14 15:35
06/17/14 15:35
Joined: Jul 2013
Posts: 34
Nagykanizsa
Robogamer Offline OP
Newbie
Robogamer  Offline OP
Newbie

Joined: Jul 2013
Posts: 34
Nagykanizsa
Hello!

I need a code snippet for the following: when we click with the right mouse button on an entity, we pick it up, and we can carry it around (it is levitating in front of the camera). With the left mouse button, we can throw it away. But with pressing right mouse button again, while we carry that entity around, we can gently put it down on the ground. This solution was in Half-Life 2. Please help me!

Thanks in advance!

Re: Physics help needed for controls similar to Half-Life 2 [Re: Robogamer] #442323
06/18/14 07:31
06/18/14 07:31
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
in your main user interface while loop check if mouse is clicked
check is there a mouse_ent
check whether it is a pickable entity or not (you can use a FLAG for it, set on level design)
use vec_for_vertex or vec_for_bone to position this item entity to your character hand (even if it is invisible)

on left click check whether the character has an item in hand
if yes, start throw animation of your character
when it is finished after some frames, set a speed to the item
decelerate item speed, apply gravitation, until hits something, or use physx

on right click check whether the character has an item in hand
if yes, detach from character, and set a gravity to the item


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: Physics help needed for controls similar to Half-Life 2 [Re: sivan] #442332
06/18/14 11:17
06/18/14 11:17
Joined: Jul 2013
Posts: 34
Nagykanizsa
Robogamer Offline OP
Newbie
Robogamer  Offline OP
Newbie

Joined: Jul 2013
Posts: 34
Nagykanizsa
Thanks, but I'd like to use PhysX-
should I attach the entity to the player with an invisible rope, while the player carries the entity?
If yes, how can I do that?

Re: Physics help needed for controls similar to Half-Life 2 [Re: Robogamer] #442350
06/19/14 07:15
06/19/14 07:15
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
I do not use physx, probably there are more experienced people around here.


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: Physics help needed for controls similar to Half-Life 2 [Re: sivan] #442822
07/03/14 21:36
07/03/14 21:36
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
one of my competition entries attached and
threw an object , it was called "moon craft" although I forgot to limit the frame rate to 60 fps
wich rendered my forces absolute , there is code
within it you could use , I used joints to do what
you describe. ..


Compulsive compiler
Re: Physics help needed for controls similar to Half-Life 2 [Re: Wjbender] #442871
07/05/14 09:49
07/05/14 09:49
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
i would use a PID controller for such things.
http://forums.tigsource.com/index.php?topic=10130.0
(only using the P or PI parts could be enough too. :))

Re: Physics help needed for controls similar to Half-Life 2 [Re: ventilator] #442882
07/05/14 10:53
07/05/14 10:53
Joined: Jul 2007
Posts: 619
Turkey, Izmir
Emre Offline
User
Emre  Offline
User

Joined: Jul 2007
Posts: 619
Turkey, Izmir
You can use pXent_setvelocity and pXent_addvelcentral. for example;

Code:
VECTOR hold_target;
VECTOR my_kick;
.....
if (event_type == EVENT_RIGHTCLICK)
	{
		while(mouse_right==1)
		{
			
			if(!mouse_left)
			{
				
				vec_set(hold_target,vector(20,0,0));
				vec_rotate(hold_target,camera.pan);
				vec_add(hold_target,camera.x);
				vec_sub(hold_target.x,my.x);
				vec_scale(hold_target.x,10);
				pXent_setvelocity(my, vector(hold_target.x, hold_target.y, hold_target.z)); 
				
				
			}
			else
			{
				
				
				my_kick.x=10;
				my_kick.y=0;my_kick.z=0;
				vec_rotate(my_kick,camera.pan);
				pXent_addvelcentral(my, vector(my_kick.x, my_kick.y, my_kick.z));
				
				break;
			}
			wait(1);
		}
		
	}



Moderated by  George 

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