- Home /
Apply force from specific location in space
Hi comunity. I'm trying to make a football game and I need that when the player gives the ball, it will can be launched from a specific point in the space with a force (a trigger, for example, and I determinates this by script). Is that behaviour possible?
Thanks for any answer.
Not sure quite what you're asking here, so let me try to rephrase it:
You want to be able to instantiate a game object at a point in space and then apply a force in a specific direction. How does the trigger fit into things?
I'm trying to say. I want to move a gameobject from A position to B position using physic force. Is this possible? And how could I do it?
You can add an impulse force :
gameObject.rigidbody.AddForce( transform.forward * forwardForce, Force$$anonymous$$ode.Impulse );
http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForce.html
though for a realistic effect you may want to AddForce at the edge of the football :
gameObject.rigidbody.AddForceAtPosition( transform.forward * forwardForce, transform.position + ( -transform.forward * ballRadius ), Force$$anonymous$$ode.Impulse );
http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForceAtPosition.html
different force modes : http://docs.unity3d.com/Documentation/ScriptReference/Force$$anonymous$$ode.html
Thank you my friend, but maybe I did'nt understand enough fact. I know how add force to the gameobjects. But now, I need to add a scpecific force to my sphere that addresses exactly from a point A to a point B, I need to apply the exactly force necessary to reach the point B. I think that now I have become better understood.
Thank You!
I see. Have converted my answer to a comment. You may want something from these links, Aldo has all the answers for this type of thing :
http://answers.unity3d.com/questions/148399/shooting-a-cannonball.html
http://answers.unity3d.com/questions/145972/how-to-make-enemy-canon-ball-fall-on-mooving-targe.html
http://answers.unity3d.com/questions/296749/display-arc-for-cannons-ball-trajectory.html
Your answer
Follow this Question
Related Questions
Finding Position based on a local perspective 1 Answer
Position waypoint along sphere 1 Answer
Problem stopping rigid body after adding a force 0 Answers
Find world position of a Texture2D 2 Answers