Preview(Asset asset)
        {
            targetRig = AnimationRig.Create(asset.DestinationAvatar);

            int trajectoryLength = Missing.truncToInt(2.0f * asset.TimeHorizon * asset.SampleRate) + 1;

            sampleTrajectory = Trajectory.Create(trajectoryLength, Allocator.Persistent);
            timeHorizon      = asset.TimeHorizon;
            assetSampleRate  = asset.SampleRate;

            trajectoryColor = Binary.TrajectoryFragmentDisplay.CreateOptions().baseColor;
        }
Пример #2
0
    private void Update()
    {
        trajectory.Clear();

        Vector3 mousePosition = Input.mousePosition;

        mousePosition.z = 10;
        mousePosition   = Camera.main.ScreenToWorldPoint(mousePosition);

        float power = Vector3.Distance(mousePosition, transform.position);

        Vector3 direction = (mousePosition - transform.position).normalized;

        if (Input.GetMouseButton(0))
        {
            trajectory.Create(transform.position, direction * power * powerMultiplier);
        }

        if (Input.GetMouseButtonUp(0))
        {
            Instantiate(ball, transform.position, Quaternion.identity).GetComponent <Rigidbody>().AddForce(direction * power * powerMultiplier);
        }
    }