- Home /
adding Up force
So right now im using the script below to add up force to an object by picking an axis i want it to pull. the problem is when i add up force, the objects vibrate a bit as they go up and i want it to be smooth. here is the script (btw the script i added below this one would be more convenient form me to add an up force to it) :
private List<GameObject> pullObjects;
public Vector3 pullDirection;
public float pullSpeed;
public float PullStrength;
void Start () {
pullObjects = new List<GameObject> ();
}
void Update () {
foreach (GameObject obj in pullObjects) {
obj.transform.Translate (Time.deltaTime * pullSpeed * pullDirection,transform);
}
}
public void OnTriggerEnter(Collider coll)
{
if (coll.gameObject.gameObject.tag == "Untagged") {
pullObjects.Add (coll.gameObject);
}
}
public void OnTriggerExit(Collider col)
{
if (col.gameObject.gameObject.tag == "Untagged") {
pullObjects.Remove (col.gameObject);
}
}
} here is the script i would like to add up force to, but if you cant just add it to the one above.
private GameObject PullOBJ;
public float PullSpeed;
public float objRotationSpeed;
public float rotation;
public float PullStrength;
public void OnTriggerStay (Collider coll)
{
if (coll.gameObject.tag == "Untagged") {
PullOBJ = coll.gameObject;
PullOBJ.transform.position = Vector3.MoveTowards (PullOBJ.transform.position, this.transform.position, PullSpeed * Time.deltaTime);
PullOBJ.transform.RotateAround (transform.position, Vector3.up, Time.deltaTime * rotation);
PullOBJ.transform.Rotate (Vector3.left, 45 * Time.deltaTime * objRotationSpeed);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
pulling objects 1 Answer
pulling in objects one end, and releasing out the other 0 Answers
pulling objects across a collider 0 Answers
Push/Pull Physics - Cube 1 Answer
adding force 1 Answer