Forum rules - please read before posting.

I want to move object to only X direction or only Y direction or only Z direction by Moveable.

Hello. I want to move object to only X direction or only Y direction or only Z direction by Moveable function. Please tell me what should I do.

Comments

  • By "Moveable function", you mean to move a Moveable component over time?

    Are you looking to move by a certain amount in a given direction? You can use the Object: Transform Action's By option to move along a single axis.

    If you want to move to a specific position, that has the e.g. same X and Y values as the object, but a different Z, then you'll need to make use of a custom script to place a Marker at the intended desination - and then use the Object: Transform Action's Copy Marker feature to move the object to the Marker.

    For example, this script - attached to a Marker - gives you three functions to have it set two of its axes to match the Moveable object, while keeping the remaining axis fixed:

    using UnityEngine;
    using AC;
    
    public class RepositionMarker : MonoBehaviour
    {
    
        public Moveable moveable;
    
        public void SnapX ()
        {
            transform.position = new Vector3 (transform.position.x, moveable.transform.position.y, moveable.transform.position.z);
        }
    
        public void SnapY ()
        {
            transform.position = new Vector3 (moveable.transform.position.x, transform.position.y, moveable.transform.position.z);
        }
    
        public void SnapZ ()
        {
            transform.position = new Vector3 (moveable.transform.position.x, moveable.transform.position.y, transform.position.z);
        }
    
    }
    

    You can use the Object: Call event or Object: Send message Action to trigger its SnapX, SnapY or SnapZ functions to teleport it before using the Object: Transform Action to move the Moveable object towards it over time.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.