Hello. Need a Gravity gun in half-life … All that I found on the forum, not working.
Maybe anybody upload example here…
Dear Webwolf,
The Forum exists to help others finding their own solution. It’s not like “I need this, give me that.”
If you want a Gravity Gun 3D Model, you’ll have to model one. If you’d like to have a script that generates physical behaviour similar to the Gravity Gun, you’ll have to learn how to work with Physics. The Unity documentation is a good point to start learning!
Greetz
You can try this link that is a store that has what you are looking for and the gravity gun is free ! :http://unity3dmall.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=27&category_id=3&vmcchk=1&option=com_virtuemart&Itemid=5
have fun
Agreed. Help then find a solution to implement the idea.
asking what I was thinking that someone simply is already there. I would not say what would someone do it … I just have not much time, I would like to find a solution from which to move forward.
I found this script but this is not true… object rotating. I will try fix it.
var pointDistance = 3.0;
var pullSpeed = 8.0;
var throwForce = 40.0;
private var mGrabbed : boolean = false;
private var heldObject : Transform;
function Update()
{
if(mGrabbed){
var targetPoint = Camera.main.transform.TransformPoint(Vector3.forward * pointDistance);
heldObject.position=Vector3.Lerp(heldObject.position, targetPoint, Time.deltaTime * pullSpeed);
}
if(Input.GetButtonDown("Fire2")){
if(!mGrabbed){
var ray : Ray = camera.ViewportPointToRay (Vector3(0.5,0.5,0));
var hit : RaycastHit;
if (Physics.Raycast (ray, hit)){
print(hit.transform.name);
if(hit.rigidbody){
heldObject = hit.transform;
heldObject.rigidbody.useGravity=false;
mGrabbed = true;
}
}
}else{
heldObject.rigidbody.velocity=Camera.main.transform.forward * throwForce;
mGrabbed = false;
heldObject.rigidbody.useGravity=true;
}
}
}
I’m fixed problem with rotation. Now, how i can fix when object twitches after Collision ?
the twitch is from insufficient physics solver calculations. To increase, goto Unity’s top menu
Edit → Project Settings → Physics ::: Solver Iteration Count = n
//*** n probably 20, as this is “stock” setting.
Raise n to 30 and try again playing your game. Then if still twitch, try 50.
I’ve done tests with it as high as 100 and not seen physics cripple gameplay speed or hog the cpu with 32 physics objects using it. So it’s not really all that heavy on CPU on a PC/Mac. iPhone probably different.
Ignore Iunio. I think he’s going through manopause.
But there is no point in reinventing the wheel, so asking if there is already one made is perfectly fine.