How do I make an object travel making a parable.

  • .

  • davy421

    Thank you Colludium this works great! What I'm trying to do now, is translate this into code into Unity. I'm not sure if you're familiar with it, but I get a bug where the arrows just fly off into space, like rockets. For now, to avoid complexity, I'm not using shadows, but still, no luck. This is the code I'm using:

    To set up the arrow (left click in your demo):

    >         angleTowardX = target.position.x;
            angleTowardY = target.position.y;
            lastX = transform.position.x; // Get the possition of the arrow
            lastY = transform.position.y;
            launch_time = Time.time;
            Vector2 launcher = new Vector2(transform.position.x, transform.position.y);
            Vector2 aimpoint = new Vector2(target.position.x, target.position.y);
            flight_time = Vector2.Distance(launcher, aimpoint) ; // Not using the shadow bullet speed here
            Y_init_velocity = (float)0.5 * flight_time; // Not using the accelerator here[/code:3t219d1t]
    Each frame I do:
             time_of_flight = launch_time - Time.time;
            // Set the position of the arrow
            transform.position = new Vector3(transform.position.x, (float)(transform.position.y - Y_init_velocity * time_of_flight + 0.5 * Y_accel * Mathf.Pow(time_of_flight, 2)), transform.position.z);
            // Calculating the rotation
            Vector2 last = new Vector2(lastX, lastY);
            Vector2 current = new Vector2(transform.position.x, transform.position.y);
            // Not sure if this line works correctly, could this be it?
            Quaternion rotation = Quaternion.Euler(Vector2.Angle(last, current), 0, 0);
            transform.rotation = rotation;
            lastX = transform.position.x;
            lastY = transform.position.y;[/code:3t219d1t]

    This forum, and particularly this section, is for questions on C2. If you have questions on Unity, then you should be asking on their forums, rather than here.

    Getting a C2 user to go out of their way to create something for you just so you can convert it to Unity is quite frankly a disgrace.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • davy421

    Editing out what you posted is pointless - that's why I quoted it. This just puts you in an even worse light.

    It would have been better just to apologize and move on.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)