[Scripting] - Moving prop relatively to player (Solved)

Users who are viewing this thread

I am trying to move a scene prop relatively from the player's position. However my knowledge of
the Module System synthax does not go that deep.

The intention is to move a scene prop, using the arrow keys. This works well with the common y and x coordinats of the map, using this script:

Code:
	(0, 0, 0, [(eq, "$colony_is_building", 1), (key_is_down, key_right),], 
		[(prop_instance_get_position, pos0, reg0),
	         (position_move_x, pos0, "$colony_building_movement_pos"),
                 (prop_instance_animate_to_position, reg0, pos0, 1),
		]),

This will move the scene prop to the right side, only if the player is looking in the desired direction.
Can you guys help to get this working, even when the player looks at another direction?
I do not require additional information about rotation or relative rotation from player's pos.

I guess I need one of these two:

position_transform_position_to_local
or
position_transform_position_to_parent
 
add the 3 lines below
Code:
(0, 0, 0, [(eq, "$colony_is_building", 1), (key_is_down, key_right),],
		[(prop_instance_get_position, pos0, reg0),
                 (get_player_agent_no,":player"),#gets player agent
                (agent_get_look_position, pos2, ":player"),#gets the position the player is looking at
                (position_copy_rotation, pos0, pos2),#copys rotation from pos2 to pos0
	         (position_move_x, pos0, "$colony_building_movement_pos"),
                 (prop_instance_animate_to_position, reg0, pos0, 1),
		]),
 
Im not sure I understand what you mean then, you could possibly try this, this will mean that the prop doesnt rotate but moves relative to the camera.
Code:
(0, 0, 0, [(eq, "$colony_is_building", 1), (key_is_down, key_right),],
		[(prop_instance_get_position, pos0, reg0),

                (position_copy_rotation, pos1, pos0),#copys rotation from pos0 to pos1 for temporary storage
                 (get_player_agent_no,":player"),#gets player agent

                (agent_get_look_position, pos2, ":player"),#gets the position the player is looking at
                (position_copy_rotation, pos0, pos2),#copys rotation from pos2 to pos0
	         (position_move_x, pos0, "$colony_building_movement_pos"),

                (position_copy_rotation, pos0, pos1),#copys rotation original rotation back
                 (prop_instance_animate_to_position, reg0, pos0, 1),
		]),
 
Back
Top Bottom