[BUG ?] fX, fY, fZ in OnPlayerWeaponShot
#1

pawn Код:
//I created 2 objects with different rotations.
    CreateObject(6959, 17.18580, -58.10570, 2.61260,   0.00000, 90.00000, 0.00000); //hitid 1
    CreateObject(6959, 17.18580, -18.14240, 2.61260,   180.00000, 90.00000, 0.00000); //hitid 2


public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    new Float:X, Float:Y, Float:Z;
    switch(hittype)
    {
        case BULLET_HIT_TYPE_OBJECT: GetObjectPos( hitid, X, Y, Z );
    }
    CreateObject(1946, X - fZ, Y - fY, Z + fX, 0, 0, 0, 100); //You may noticed I put fZ in X, and fX in Z in CreateObject. And On X and Y I used minus, on Z, I used plus symbol.
//I don't know why, but it works perfect on hitid 1, but it doesn't work properly on hitid 2. Watch the video below;
    return 1;
}
[ame]http://www.youtube.com/watch?v=jIPYxbf_MSc[/ame]
Reply
#2

The offsets assume a default object rotation.
Reply
#3

That means.. in order to use the function, objects' rotations must be 0,0,0?
Reply
#4

Quote:
Originally Posted by FUNExtreme
Посмотреть сообщение
The offsets assume a default object rotation.
Yes. The offsets are related to the object's axes:
Код:
CreateObject(6959, 17.18580, -58.10570, 2.61260,   0.00000, 0.00000, 0.00000);
If you shoot the easternmost corner of this object, you will get an offset of around X=20, when you rotate the object around 180 on the Z axis,
Код:
CreateObject(6959, 17.18580, -58.10570, 2.61260,   0.00000, 0.00000, 180.00000);
the same spot will output X=-20.

Код:
CreateObject(6959, 17.18580, -58.10570, 2.61260,   0.00000, 0.00000, 90.00000);
This will output Y=-20
So you see where the problem is. In your test you are applying the offsets to the world's axes, and not the object's axes. You'll have to do some calculations which also contain the angles of the objects so you can determine where to place these orange balls precisely.
Reply
#5

I used GetObjectPos(); - I dont know what are the advantages of using this in the callback but just for a solution. The advantage is it gets the X Y Z axis of the object.
Reply
#6

Quote:
Originally Posted by Drebin
Посмотреть сообщение
No. The offsets are related to the object's axes:
Код:
CreateObject(6959, 17.18580, -58.10570, 2.61260,   0.00000, 0.00000, 0.00000);
If you shoot the easternmost corner of this object, you will get an offset of around X=20, when you rotate the object around 180 on the Z axis,
Код:
CreateObject(6959, 17.18580, -58.10570, 2.61260,   0.00000, 0.00000, 180.00000);
the same spot will output X=-20.

Код:
CreateObject(6959, 17.18580, -58.10570, 2.61260,   0.00000, 0.00000, 90.00000);
This will output Y=-20
So you see where the problem is. In your test you are applying the offsets to the world's axes, and not the object's axes. You'll have to do some calculations which also contain the angles of the objects so you can determine where to place these orange balls precisely.
You said the exact same thing I did, with a lot more words. The offsets assume a DEFAULT (0.0) object ROTATION.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)