- Home /
Help with SlingShot trajectory...
I have this script of a Slingshot...
using UnityEngine; using System.Collections;
public class slingshot : MonoBehaviour {
public Vector2 click;
public Vector2 Soltado;
public float multiplicador;
public float minimo_estirado;
public float maximo_estirado;
public int potencia = 1000;
public GameObject pers;
public Rigidbody2D rb;
// Use this for initialization
void Start () {
rb = pers.GetComponent<Rigidbody2D>();
rb.isKinematic = true;
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown (0)) {
click = Input.mousePosition;
Debug.Log ("" + click);
}
if (Input.GetMouseButtonUp (0)) {
rb.isKinematic = false;
Soltado = Input.mousePosition;
Debug.Log ("" + Soltado);
var direccion = click - Soltado;
direccion.Normalize ();
rb.AddForce (direccion * potencia);
}
}
}
And I wan't to do a dotted trajectory... but how? xD
Comment
Answer by alankemp · Feb 06, 2017 at 02:42 PM
Try this article:
https://tech.spaceapegames.com/2016/07/05/trajectory-prediction-with-unity-physics/
Your answer
Follow this Question
Related Questions
line render from object to object 1 Answer
Have a line renderer appear over a sprite? 1 Answer
Trail renderer algorithm? 0 Answers
line renderer problem 0 Answers
Particle system and line renderer doesn't work in Maximized Window 1 Answer