SA-MP Forums Archive
Why moveobject doesn't work - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Why moveobject doesn't work (/showthread.php?tid=647316)



Why moveobject doesn't work - MasterCodez - 03.01.2018

Quote:
Originally Posted by ATomas
Посмотреть сообщение
Use this:




x0,y0 - start position
t - time (1,2,3,4,5..., you can use Float for better results)
alpha - angle for shoot
v0 - speed of shoot
g - gravitation (9.806)
x,y - current position for object in time t


cyklus for t (time) + caltulate position in time (more times it's better look, but many calculates).

I had used for golf engine on my server and works fine.
PHP код:
stock MoveFire(Float:xFloat:yFloat:zFloat:angle)
{
    new 
Floattx;
    new 
Floatty;
    new 
time 3;
    
tx 100*time*floatcos(angle);
    
ty 100*time*floatsin(angle)-1/2*9.806*time*time;
    new 
DynamicObject CreateDynamicObject(2064xyz,   0.000000.000000.00000);
    
MoveDynamicObject(DynamicObjecttxtyz3.0);
    return 
1;
}
CMD:test(playeridparams[])
{
    new 
Float:x,Float:y,Float:z;
    new 
Float:angle;
        
GetPlayerPos(playeridxyz);
        
GetPlayerFacingAngle(playeridangle);
        
MoveFire(xyzangle);
    return 
1;




Re: Why moveobject doesn't work - jasperschellekens - 03.01.2018

Quote:
Originally Posted by MasterCodez
Посмотреть сообщение
PHP код:
stock MoveFire(Float:xFloat:yFloat:zFloat:angle)
{
    new 
Floattx;
    new 
Floatty;
    new 
time 3;
    
tx 100*time*floatcos(angle);
    
ty 100*time*floatsin(angle)-1/2*9.806*time*time;
    new 
DynamicObject CreateDynamicObject(2064xyz,   0.000000.000000.00000);
    
MoveDynamicObject(DynamicObjecttxtyz3.0);
    return 
1;
}
CMD:test(playeridparams[])
{
    new 
Float:x,Float:y,Float:z;
    new 
Float:angle;
        
GetPlayerPos(playeridxyz);
        
GetPlayerFacingAngle(playeridangle);
        
MoveFire(xyzangle);
    return 
1;

Try it on a different way, dynamic object didnt work for me either.
This is an example that i use on my gamemode:

Код:
new closeddoor13;

//under ongamemodeinit
closeddoor13=CreateObject(2930, 2571.82983, -1532.14771, -47.34000,   0.00000, 0.00000, 90.00000);
// execute with OpenDoor13(playerid, 5000);

stock OpenDoor13(playerid, time)
{
    new str[128];
    MoveObject(closeddoor13, 2573.22778, -1532.11182, -47.34000, 2.0);
	format(str,sizeof(str),"%s(%i) inserts an code and presses the confirm button.",PlayerName(playerid),playerid);
	SetTimerEx("CloseDoor13", time, false, "i", playerid);
	SendNearbyMessage(playerid,30.0,str,ORANGE);
}
forward CloseDoor13(playerid);
public CloseDoor13(playerid)
{
    MoveObject(closeddoor13, 2571.82983, -1532.14771, -47.34000, 2.0);
}



Re: Why moveobject doesn't work - MasterCodez - 03.01.2018



That script will be move like this?


Re: Why moveobject doesn't work - Logic_ - 03.01.2018

You have to modify the Z axis to make the object move but also keep in your mind about the default object rotations! Moving objects from wrong rotations cause them to teleport to their new position rather than actual movement like you want to see (Note: Changing z axis don't affect it)

EDIT: you need to make the variable global if you want have one object which changes it's position when you execute the command.