Movement from box to box

Hello,
Is it possible someone to help me with cube moving. The goal is when u click on your Phone screen (selecting the object(other box) the player to jump on it).

160246-jumpfromboxtobox.png

Thanks for the help!

Regards!

If I understand correctly. Do you want the sphere in the image on the right to jump to the other platform when clicked? if so, then

  1. I would implement a MouseClick function on the object you want to jump to.

  2. Add an impulse force to the rigid body you want to make jump and this impulse would be straight up and distance from the other platform * the x,z components (if using for different distances of platforms later)
    Forgive me if my vector direction is wrong as I usually only work in 2d and my coordinates to move are x,y and in 3d space, I think they use x,z

    public void jumpTrigger(GameObject objectToJumpTo)
    {
    float distanceScale = 1; //Increases distance influence on jump velocity
    float jumpHorizontalSpeed = 1;
    float jumpHeight = 1;
    float distance = Vector3.Distance(objectToJumpTo.transform.position, yourGameobject.transform.position); //Increases jump distance
    Vector3 vectorComponets = objectToJumpTo.transform.position - yourGameobject.transform.position; //Get angle in vector form between both objects
    vectorComponets = vectorComponets.normalized;

         yourRigidbody.AddForce(new Vector3(vectorComponets.x*(jumpHorizontalSpeed*(distance*distanceScale)),jumpHeight, vectorComponets.z*(jumpHorizontalSpeed * (distance * distanceScale))));
     }
    

This may or may not work right off the bat, but should give you an idea on how to proceed.
I also know that I could have left the normalized off, but it helps to see how the code snaps together to give horizontal velocity. Good luck with your project!