- Home /
rotating objects around collider axis
so i have a collider and i use this script to make rigidbodies to get pulled to it and rotate around it for my tornado. but a problem im having is the tornado releasing objects it picks up. so i wanted to tilt the collider (capsol collider sideways to create a sidways rotation which would pick objects up then smash them into the ground forcing them away therefore releasing them. but the problem im having is taht when i rotate the collider it still rotates other objects the same. so i was wondering what to add to theis script so that if i attatch a collider it will roatate around the colliders y axis, so even if i tilt the collider it will rotate the way it rotates aswell. hopefull that makes sence. here is the script i attach to the collider.
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);
}
}
Answer by Priyanka-Rajwanshi · Apr 18, 2018 at 04:39 AM
@Jdogmaster The collider's y-axis is PullOBJ.transform.up and your tornado's y axis would be transform.up(Considering the script is on tornado)
Thanks man I’ll try it out tomarrow and let u know how it goes. Btw the visible tornado is just a rotating partical system with no scripts attached to it. I then have a few capsules extending from the center we with the varying strengths.
Is the above script then attached to an empty gameobject? transform.up would give the up vector respective to the gameobject on which the script is attached to.
no actually the above script is attached to each of the colliders extending from the particle system. so each collider has a different pull force to attract objects