below is my push script.
public float pushPower= 2.0f;
void OnControllerColliderHit (ControllerColliderHit hit)
{
Rigidbody body = hit.collider.attachedRigidbody;
if (body == null || body.isKinematic)
return;
if (hit.moveDirection.y < -0.3f)
return;
if(hit.collider != null && hit.collider.gameObject.tag == "PullThis" && Input.GetKeyDown(KeyCode.E))
{
Vector3 pushDir = new Vector3 (hit.moveDirection.x, 0, hit.moveDirection.z);
body.velocity = pushDir * pushPower;
}
}
At first I thought, all I have to do is press some key and then do exactly the other way of pushing by inserting “-” in Vector 3 x and z, which didn’t work. I’ve been following other tutorials and answers as well, but still can’t figure out.
Also, there’s another tutorial I’m following for pulling object but that’s for 2D game. I’ve been trying to convert into 3D components as much as I can but I hit the wall with
Physics2D.queriesStartInColliders = false;
Is there something like that checks rays/lines without arguments(no Linecast) in Physics? (or ways to check).
So, if you guys can help me with:
#1. example of codes based on push script
or
#2. similar ways to check rays/lines like Physics2D.queriesStartInColliders = false;
It’d be much appreciated.
Thanks for help in advance.