Phy.inc
#1

Hi all , i have an problem with physics.inc (i never used it before so...idk sure what's wrong )
So , my problem it's ... the object won't move.

Код HTML:
CMD:testmove(playerid,params[])
{
  new Float:spd;
  if(sscanf(params,"f",spd))
    return SendClientMessage(playerid,-1,"Usage: /testmove [Speed]");

  PHY_SetObjectVelocity(Biliard[AccInfo[playerid][InPool]][Ball][0], 0.0, -speed);
  return 1;
}
Код HTML:
stock InitBall(PoolID,i)
{
    PHY_InitObject(Biliard[PoolID][Ball][i], 3003, _, _, Ex_MODE_2D);
    PHY_SetObjectFriction(Biliard[PoolID][Ball][i], 0.40);
    PHY_RollObject(Biliard[PoolID][Ball][i]);
    PHY_SetObjectWorld(Biliard[PoolID][Ball][i], 3);
    Biliard[PoolID][bExist][i] = 1;
}
Biliard[PoolID][Ball][0] = CreateObject(3003, 0.010589+Biliard[PoolID][x], 0.428184+Biliard[PoolID][y], 0.930358+Biliard[PoolID][z], 0, 0, 0);

What i should do?

EDIT: And at stock InitBall i get akslimit.
Reply
#2

this thing doesnt make sense
Reply
#3

https://github.com/uPeppe/Object-Phy...de/physics.inc
Reply
#4

You could also achieve similar results using an updated and simpler version of Physics include:

https://sampforum.blast.hk/showthread.php?tid=630602

PHP код:
#define MAX_BALLS 5
enum E_BALL_DATA {
    
BALL_OBJECT,
    
BALL_PROJECTILE
};
new 
balls[MAX_BALLS][E_BALL_DATA];
public 
OnGameModeInit() {
    for (new 
0MAX_BALLSi++) {
        
balls[i][BALL_OBJECT] = CreateDynamicObject(..); // create your ball objects here
    
}
    return 
1;
}
CMD:testmove(playerid,params[]) {
    new 
ballidFloat:spd;
    if(
sscanf(params,"if",spd))
        return 
SendClientMessage(playerid,-1,"Usage: /testmove [Ballid] [Speed]");
    new 
Float:xFloat:yFloat:z;
    
GetDynamicObjectPos(balls[ballid][BALL_OBJECT], xyz);
    
// "aim_angle" will be the angle player is aiming the ball to go in direction
    // since we are dealing with 2D physics, set "vz" to 0.0
    
balls[ballid][BALL_PROJECTILE] = Projectile(xyzspeed floatsin(-aim_angledegrees), speed floatcos(-aim_angledegrees), 0.0, .ground_friction 0.40);
    return 
1;
}
public 
OnProjectileUpdate(projid) {
    new 
Float:xFloat:yFloat:z;
    for (new 
0MAX_BALLSi++) {
        if (
projid == balls[i][BALL_PROJECTILE]) {
            
// update the object position when projectile updates
            
GetProjectilePos(projidxyz);
            
SetDynamicObjectPos(balls[i][BALL_OBJECT], xyz);
            
// update rotation
            
GetProjectileRot(projidxyz);
            
SetDynamicObjectRot(balls[i][BALL_OBJECT], xyz);
      
        }
    }
}
public 
OnProjectileCollide(projidtypeFloat:xFloat:yFloat:zextraid) {
    for (new 
0MAX_BALLSi++) {
        if (
projid == balls[i][BALL_PROJECTILE]) {
            if (
type == 3) { // ball collided with an object
                // do your stuff here !
            
}
        }
    }

Reply
#5

Thanks , but i want to resolve my script bcz it's almost done. But i have only this problem .
I really don't know why it's making this to me. It can be bcz i have this enum like that?

Код HTML:
enum benum
{
...
 Ball[16],
...
}

new Biliard[MAX_POOL][benum];
Reply
#6

projectile doesn't have object rotation.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)