SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 28/06/2013, 06:57 PM   #41
Inverse
Huge Clucker
 
Inverse's Avatar
 
Join Date: Jun 2011
Location: Braavos
Posts: 251
Reputation: 19
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

Fantastic!
Inverse is offline   Reply With Quote
Old 29/06/2013, 05:39 PM   #42
PeppeAC
Big Clucker
 
Join Date: Jun 2013
Location: Trani, Italy
Posts: 89
Reputation: 192
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

New example command:
Code:
command(launch, playerid, params[])
{
	#define SPEED (10.0)
	#define Z_SPEED (4.0)
	#define GRAVITY (13.0)
        new modelid = 348; // Deagle Model ID
	new Float:x, Float:y, Float:z, Float:ang;
	GetPlayerPos(playerid, x, y, z);
	GetPlayerFacingAngle(playerid, ang);
	new obj = CreateObject(modelid, x, y - 0.5 * floatcos(-(ang + 90.0), degrees), z, 93.7, 120.0, ang + 60.0);
 	PHY_InitObject(obj);
	PHY_SetObjectVelocity(obj, SPEED * floatsin(-ang, degrees), SPEED * floatcos(-ang, degrees), Z_SPEED);
	PHY_SetObjectFriction(obj, 100); // This will stop the object when it touchs the ground.
	PHY_SetObjectGravity(obj, GRAVITY);
	PHY_SetObjectZBound(obj, z - 1.0, _, 0.0);
	ApplyAnimation(playerid,"GRENADE","WEAPON_throwu",3.0,0,0,0,0,0);
	return 1;
}
Throws a deagle (you can change easily the object modelid, but this code works well specially for weapons) in front of the player. You can adjust SPEED, Z_SPEED and GRAVITY to obtain a realistic effect.

Last edited by PeppeAC; 20/09/2014 at 08:33 AM.
PeppeAC is offline   Reply With Quote
Old 30/06/2013, 05:16 PM   #43
cyber_punk
Huge Clucker
 
Join Date: Feb 2008
Location: Det. Mi. USA.....
Posts: 435
Reputation: 10
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

Very nice, any way to make a timer less version? Either using OnObjectMoved or Incognitos streamer's area system? Not a huge fan of 20 millisecond timers looping through every physic object on a server with large player numbers.
__________________
cyber_punk is offline   Reply With Quote
Old 30/06/2013, 06:33 PM   #44
PeppeAC
Big Clucker
 
Join Date: Jun 2013
Location: Trani, Italy
Posts: 89
Reputation: 192
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

Quote:
Originally Posted by cyber_punk View Post
Very nice, any way to make a timer less version? Either using OnObjectMoved or Incognitos streamer's area system? Not a huge fan of 20 millisecond timers looping through every physic object on a server with large player numbers.
I know that 20 ms timers are inefficient, specially with large player numbers, but I think there isn't a way to make this without timers.
However you can modify PHY_TIMER_INTERVAL into the include to 40 ms. It should still work well.
PeppeAC is offline   Reply With Quote
Old 30/06/2013, 06:44 PM   #45
Kar
Banned
 
Join Date: May 2010
Location: Black Asylum
Posts: 2,938
Reputation: 538
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

so this won't work properly with moveobject? maybe attempting to find things like straight lines e.g what the ball does and move them using moveobject?
Kar is offline   Reply With Quote
Old 30/06/2013, 07:24 PM   #46
IstuntmanI
High-roller
 
IstuntmanI's Avatar
 
Join Date: Mar 2009
Location: Romania
Posts: 1,801
Reputation: 375
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

Quote:
Originally Posted by Kar View Post
so this won't work properly with moveobject? maybe attempting to find things like straight lines e.g what the ball does and move them using moveobject?
With MoveObject it isn't working fine, because MoveObject is not smooth if you call it when the object is already moving (from a previous MoveObject), it is stopping for few milliseconds (you can notice it).

Suggestion: In future you could make it a plugin, for more performance, and in another thread to don't "stuck" the server when an object is moving.
__________________


IstuntmanI is offline   Reply With Quote
Old 01/07/2013, 02:31 AM   #47
cyber_punk
Huge Clucker
 
Join Date: Feb 2008
Location: Det. Mi. USA.....
Posts: 435
Reputation: 10
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

Quote:
Originally Posted by IstuntmanI View Post
With MoveObject it isn't working fine, because MoveObject is not smooth if you call it when the object is already moving (from a previous MoveObject), it is stopping for few milliseconds (you can notice it).

Suggestion: In future you could make it a plugin, for more performance, and in another thread to don't "stuck" the server when an object is moving.
Thats why you move the object in steps. I use it just fine for the throwing arch in the flash bangs and zombie bait in my script I notice no "stops" in the throwing of these objects.
__________________
cyber_punk is offline   Reply With Quote
Old 01/07/2013, 08:06 AM   #48
PeppeAC
Big Clucker
 
Join Date: Jun 2013
Location: Trani, Italy
Posts: 89
Reputation: 192
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

Quote:
Originally Posted by cyber_punk View Post
Thats why you move the object in steps. I use it just fine for the throwing arch in the flash bangs and zombie bait in my script I notice no "stops" in the throwing of these objects.
You can't get a realistic movement with SA-MP MoveObject, because of the impossibility to set object's acceleration. And moving the object in steps doesn't make a fluid and realistic movement.
PeppeAC is offline   Reply With Quote
Old 04/07/2013, 07:30 AM   #49
PeppeAC
Big Clucker
 
Join Date: Jun 2013
Location: Trani, Italy
Posts: 89
Reputation: 192
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

Objects Physics 0.2 update available:
  • PHY_ObjectDelate renamed to PHY_DeleteObject.
  • Wall collisions fixed and improved.
  • Added optional "constant" parameter to PHY_CreateWall, like in PHY_SetObjectZBound.
  • Failed attempt to make a better ball rolling using quaternions. See the internal function PHY_Rall if you want to try to fix it.

https://github.com/uPeppe/Object-Physics
PeppeAC is offline   Reply With Quote
Old 05/07/2013, 09:56 PM   #50
PeppeAC
Big Clucker
 
Join Date: Jun 2013
Location: Trani, Italy
Posts: 89
Reputation: 192
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

Another example of what you can do with this include:
[ame]http://www.youtube.com/watch?v=XXoF2ExL0Po[/ame]
PeppeAC is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Player Camera Goes Trough Objects And Attached Objects. [WSF]ThA_Devil Scripting Help 1 20/11/2013 02:40 PM
Handle multiple objects. HeLiOn_PrImE Scripting Help 5 08/04/2012 06:32 AM
If I create the objects in virtual worlds that makes room for other objects? tal_peretz Help Archive 8 17/05/2011 01:48 PM
Question regarding objects, collisions Biesmen Help Archive 5 25/03/2011 06:27 AM
Making objects, deleting created objects KnooL Help Archive 1 15/02/2009 08:34 AM


All times are GMT. The time now is 01:46 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.