Hello everyone.

We have decided to phase out the Mixed Reality Forums over the next few months in favor of other ways to connect with us.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

The plan between now and the beginning of May is to clean up old, unanswered questions that are no longer relevant. The forums will remain open and usable.

On May 1st we will be locking the forums to new posts and replies. They will remain available for another three months for the purposes of searching them, and then they will be closed altogether on August 1st.

So, where does that leave our awesome community to ask questions? Well, there are a few places we want to engage with you. For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality. If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers. And always feel free to hit us up on Twitter @MxdRealityDev.

How do I make an object slowly come into the scene?

Hi guys,

I'm a beginner. Now I'm programming a demo to show how you need to assamble a part. I want to show the part and then make it slowly move to the defined position.
How can I do it?

This is what I got now but it's to fast and not smooth

public void Update()
{
if (stepCountUp == 1)
{
while (GameObjects[0].transform.position.x >= -2)
{
Time.timeScale = 0.000000000000001f;
GameObjects[0].transform.Translate(new Vector3(-2f, 0, 0) * speed * Time.deltaTime);

        }


    }
}

Best Answer

  • JimRodrJimRodr
    Accepted Answer

    Vector3 spot = Vector3.MoveTowards(transform.position, idealLocation, 0.01f);
    transform.position = spot;

    I have had good success using MoveTowards to have objects slowly go from where they are to where I want them to end up. The third parameter is how much to move and can be calculated using a desired speed * Time.DeltaTime to be more precise/move smoother than a constant like 0.01f does.

Answers

  • This is probably a question that is more for the unity forum I am afraid.

  • JimRodrJimRodr
    Accepted Answer

    Vector3 spot = Vector3.MoveTowards(transform.position, idealLocation, 0.01f);
    transform.position = spot;

    I have had good success using MoveTowards to have objects slowly go from where they are to where I want them to end up. The third parameter is how much to move and can be calculated using a desired speed * Time.DeltaTime to be more precise/move smoother than a constant like 0.01f does.

Sign In or Register to comment.