[Include] projectile.inc - PeppeAC's physics modified and simpler version
#21

The Z position of the object doesn't change - It slides to its end position in mid-air: http://i.imgur.com/HHUBROq.png
I understand that collisions with the projectile and the CA map are done internally, right? Objects don't simulate collisions yet?
Reply
#22

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
The Z position of the object doesn't change - It slides to its end position in mid-air: http://i.imgur.com/HHUBROq.png
I understand that collisions with the projectile and the CA map are done internally, right? Objects don't simulate collisions yet?
http://i.imgur.com/qicFj3V.jpg
I tested the example and my objects are staying at ground after collision.

There's no collisions with projectiles, so if you throw a deagle and another deagle at the same time from opposite direction, they won't collide but go straight to their respective path. (and all these checks are done internally you just need to throw the deagle!)

What i can think of in your case might be player collision which might bug, did you throw the object very close to a wall?

Edit: or maybe you have a big "sphere_radius" set in Projectile function?
Reply
#23

Quote:
Originally Posted by Gammix
Посмотреть сообщение
http://i.imgur.com/qicFj3V.jpg
I tested the example and my objects are staying at ground after collision.

There's no collisions with projectiles, so if you throw a deagle and another deagle at the same time from opposite direction, they won't collide but go straight to their respective path.

What i can think of in your case might be player collision which might bug, did you throw the object very close to a wall?
I threw the deagle right in front of Jefferson motel in the middle of the street, so I guess not. To further test this, I drove to LV to test it in the middle of nowhere and same results - it just slides to its destination in mid-air.

And I meant collisions with walls and such, because that isn't working either.

EDIT: I took the example from your GitHub and didn't change anything. The code is loaded in as a filterscript.
Reply
#24

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
I threw the deagle right in front of Jefferson motel in the middle of the street, so I guess not. To further test this, I drove to LV to test it in the middle of nowhere and same results - it just slides to its destination in mid-air.

And I meant collisions with walls and such, because that isn't working either.

EDIT: I took the example from your GitHub and didn't change anything. The code is loaded in as a filterscript.
Maybe you don't have cadb in scriptfiles? I know thats a stupid question but sometimes you might forgot to add it...
Cause that can be the only reason why collisions are not working, due to unsuccessful loading of collision data.

Try it in a gamemode, edit "OnFilterScriptInit" to "main".
Reply
#25

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Maybe you don't have cadb in scriptfiles? I know thats a stupid question but sometimes you might forgot to add it...
Cause that can be the only reason why collisions are not working, due to unsuccessful loading of collision data.
I had it, but I didn't know it had to be called 'colandreas.cadb'. I didn't see the console print where it said that I was missing the data. My bad. Thanks for the support.

Nice include, very easy to use.
Reply
#26

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
I had it, but I didn't know it had to be called 'colandreas.cadb'. I didn't see the console print where it said that I was missing the data. My bad. Thanks for the support.

Nice include, very easy to use.
Thanks and you can also apply rotation to deagle to make it look better plus decrease the sphere_radius a bit so it sticks to the ground.
Reply
#27

Update v1.3.3:
- Gravity effect introduced (action = reaction), this was responsible for no bouncing before.
- Modified default param values in "Projectile" so the setting is now set for a ball like object nature.

Known bug:
- Sometimes the object goes under footpaths while sliding which cause the object to float and it never calls OnProjectileStop.
Reply
#28

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Update v1.3.3:
- Gravity effect introduced (action = reaction), this was responsible for no bouncing before.
- Modified default param values in "Projectile" so the setting is now set for a ball like object nature.

Known bug:
- Sometimes the object goes under footpaths while sliding which cause the object to float and it never calls OnProjectileStop.
Nice! Though, OnProjectileStop seems to be called prematurely. It's an annoyance when you create an object that is supposed to replace the projectile under OnProjectileStop (the replacement object would be in the air instead of on the ground).
Reply
#29

Quote:
Originally Posted by AndySedeyn
View Post
Nice! Though, OnProjectileStop seems to be called prematurely. It's an annoyance when you create an object that is supposed to replace the projectile under OnProjectileStop (the replacement object would be in the air instead of on the ground).
Can you give me example projectile which causes this bug.
Reply
#30

Quote:
Originally Posted by Gammix
View Post
Can you give me example projectile which causes this bug.
I took your example and just added the CreateObject line under OnProjectileStop because that's what roughly happens in my script:
PHP Code:
#include <a_samp>
#include <zcmd>
#include <projectile>
new iProjObject[MAX_PROJECTILES];
public 
OnFilterScriptInit()
{
    
CA_Init();
    return 
1;
}
CMD:test(playerid)
{
    new 
Float:xFloat:yFloat:zFloat:ang;
    
GetPlayerPos(playeridxyz);
    
GetPlayerFacingAngle(playeridang);
    new 
Projectile(x0.5 floatcos(-(ang 90.0), degrees), z2.0 floatsin(-angdegrees), 2.0 floatcos(-angdegrees), 4.0, .collision_friction 5.0, .sphere_radius 0.01, .gravity 13.0);
    if (
== -1)
        return 
0;
    
DestroyObject(iProjObject[i]);
    
iProjObject[i] = CreateObject(348x0.5 floatcos(-(ang 90.0), degrees), z93.7120.0ang 60.0);
    
    
ApplyAnimation(playerid,"GRENADE","WEAPON_throwu",3.0,0,0,0,0,0);
    return 
1;
}
public 
OnProjectileUpdate(projid)
{
    new 
Float:xFloat:yFloat:z;
    
GetProjectilePos(projidxyz);
    
SetObjectPos(iProjObject[projid], xyz);
    return 
1;
}
public 
OnProjectileStop(projid)
{
    new 
Float:xFloat:yFloat:z;
    
GetProjectilePos(projidxyz);
    
CreateObject(348xyz90.00.00.0);
    return 
1;

Reply
#31

Update v1.3.4:
- Fixed sphere hanging in space when colliding with a player.
- Fixed min and max height calculation.

@Andy: This version should get rid of all those issues you addressed before. Give it a try!
Reply
#32

Quote:
Originally Posted by Gammix
View Post
@Andy: This version should get rid of all those issues you addressed before. Give it a try!
Yep, thank you
Reply
#33

Update v1.3.5:
- Fixed projectile index management, poolsize method used.
- New functions:
PHP Code:
IsValidProjectile(projid);
GetProjectilePoolSize(); 
- Callback "OnProjectileCollide" has a param change, the "modelid" now is "extraid". Read the main post for info. about it.
PHP Code:
OnProjectileCollide(projidtypeFloat:xFloat:yFloat:zextraid); 
- New example of "Grenade launcher" has been added.
Reply
#34

Quote:
Originally Posted by Gammix
View Post
Update v1.3.5:
- Fixed projectile index management, poolsize method used.
- New functions:
PHP Code:
IsValidProjectile(projid);
GetProjectilePoolSize(); 
- Callback "OnProjectileCollide" has a param change, the "modelid" now is "extraid". Read the main post for info. about it.
PHP Code:
OnProjectileCollide(projidtypeFloat:xFloat:yFloat:zextraid); 
- New example of "Grenade launcher" has been added.
Great! Have your rep.
Reply
#35

Why does an object fall under the ground?

https://youtu.be/kuZfFby6OO0
Reply
#36

Quote:
Originally Posted by Kolstin
View Post
Why does an object fall under the ground?

https://youtu.be/kuZfFby6OO0
Definitely this could be the reason:
Quote:
Originally Posted by Gammix
View Post
Maybe you don't have cadb in scriptfiles? I know thats a stupid question but sometimes you might forgot to add it...
Cause that can be the only reason why collisions are not working, due to unsuccessful loading of collision data.
And be sure you initialize ColAndreas using "CA_Init();".
Reply
#37

Nice work!
Reply
#38

Why did you rename "StopProjectile()" to "DestroyProjectile()" while it doesn't make much sense? I had to edit include to get my things to work.

---
check PM for more, since not allowed to share to the public cuz of Kye.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)