Moving an attached object - 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: Moving an attached object (
/showthread.php?tid=614595)
Moving an attached object -
Ahmed21 - 10.08.2016
Hello, I have attached a safe door to a safe, and made a code to move the safe door (open it), I tried to use the command ingame, but no changes and the safe door didnt move. I'm 100 percent sure about the code.
Re: Moving an attached object -
BroZeus - 10.08.2016
You need to move the object using
https://sampwiki.blast.hk/wiki/AttachObjectToObject itself
for example i want to move a object id say 'x' which is attached to object id '
a', I will do this :
Quote:
AttachObjectToObject(x, a, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
//after say 100ms i do this :
AttachObjectToObject(x, a, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
//after say 200ms i do this :
AttachObjectToObject(x, a, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0);
//after say 300ms i do this :
AttachObjectToObject(x, a, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0)
|
This will move object slowly upwards.
EDIT:
A more easy approach would be to not attach object and move it via MoveObject().
You can add offset to safe position and then use that as door position to place it correctly without using AttachObjectToObjcet().
Re: Moving an attached object -
Ahmed21 - 10.08.2016
Quote:
Originally Posted by BroZeus
You need to move the object using https://sampwiki.blast.hk/wiki/AttachObjectToObject itself
for example i want to move a object id say 'x' which is attached to object id ' a', I will do this :
This will move object slowly upwards.
EDIT:
A more easy approach would be to not attach object and move it via MoveObject().
You can add offset to safe position and then use that as door position to place it correctly without using AttachObjectToObjcet().
|
Bro, I hate using timers, and it is bad idea for me.
Re: Moving an attached object -
BroZeus - 10.08.2016
Then do what i wrote in edit part.
Re: Moving an attached object -
Ahmed21 - 10.08.2016
Bro, if the rotation of the safe is changed, then the safe door will look dirt.
Edit: can u make an example code?
Re: Moving an attached object -
BroZeus - 10.08.2016
check
https://sampwiki.blast.hk/wiki/AttachObjectToObject
See the last parameter, and set it to 0.
Quote:
SyncRotation If set to 0, objectid's rotation will not change with attachtoid's.
|
About the code you can do like :
Код:
SetObjectPos(doorObject, safePos_x + offset_x, safePos_y + offset_y,..........);//u know where its going
//for moving:
MoveObject(doorObject, ..);
Re: Moving an attached object -
Ahmed21 - 10.08.2016
Okay thank you gonna try it out.