Move Object to Player position

  • #1, z lupoFriday, 14. June, 22:18 hodinky 3 months ago
    How to set an objects position to the players characters position? I would like to have the character to drop an object where he is positioned. The user should see the object on the correct position then as a graphic. Any idea? 

    Bažant

    8 Posts


  • #2, z esmeraldaSaturday, 15. June, 17:33 hodinky 3 months ago
    I can't think of a way without scripting.

    Add the object to your scene, but leave it positioned at 0,0. Link a condition to it and hide it by setting the condition to false (or true, depending on how you set your conditons).

    In the action that should drop the item add an "execute script" action part with this line:
    Objects["obj_name"].Offset = game.CurrentCharacter.Position
    Then change the condition, so the object is active.

    (instead of obj_name use the name of your object - the one in the list of scene objects)
    This sets the object to the position of the character, i.e. its animation center. Position of the object is defined by the upper left corner of the object image.

    Objects don't have a Position field we can access with scripting, we need to use the Offset field and to make that work properly, the objects needs to be at the (0,0) position, else the offset will be added to the position of the object.
    If the position is not quite right for you, you can either move the object from the (0,0) position or change the line of script. For example:
    Objects["obj_name"].Offset = {x = game.CurrentCharacter.Position.x - 20, y = game.CurrentCharacter.Position.y + 10}

    The numbers are in pixel.

    Zabiják klíčů

    525 Posts

  • #3, z lupoSunday, 16. June, 18:13 hodinky 3 months ago
    Like always, you are a master! Thanks a million!

    Bažant

    8 Posts

Napsat příspěvek