Moving an attached object
#1

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.
Reply
#2

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().
Reply
#3

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.
Reply
#4

Then do what i wrote in edit part.
Reply
#5

Bro, if the rotation of the safe is changed, then the safe door will look dirt.

Edit: can u make an example code?
Reply
#6

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, ..);
Reply
#7

Okay thank you gonna try it out.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)