system
1
Okay so right now i have this code
function Update()
{
if(Input.GetMouseButton(0))
{
var forward = transform.TransformDirection(Vector3.forward);
var hitInfo : RaycastHit;
if (Physics.Raycast (transform.position, forward, hitInfo, 1000)) {
print(hitInfo.collider);
}
}
}
But that just tells me what im hitting at.. how can i make it so if it hits something with a rigidbody, it will fly of as if it were a bullet? thankss
system
2
http://unity3d.com/support/documentation/ScriptReference/Rigidbody.AddForce.html
Yea... Just get the rigid body, and do .AddForce ().
function Update()
{
if(Input.GetMouseButton(0))
{
var forward = transform.TransformDirection(Vector3.forward);
var hitInfo : RaycastHit;
if (Physics.Raycast (transform.position, forward, hitInfo, 1000)) {
hitInfo.rigidbody.AddForce(_________);
}
}
}
Don't double post please! And also format your code next time please.
Thanks, also, use the 10101 button to make it look pretty like above... Just highlight, then push the button.
Good luck!