• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Dave M · Dec 16, 2010 at 10:25 PM · guitriggeraddforceforce

Is there a way to show how large a force is?

Is there a way to show how large the force is, on a texture plane with a gradient?

I have this script to throw a ball:

var cannonball : Transform; var speed : float = 500; // speed is power per second var powermax : float = 5000; var powermin : float = 100; var autoThrow : boolean = true;

function Update() {
if (Input.GetButtonDown("Fire1")) StartCoroutine("Cook"); }

// This is a co-routine. // I used the term "to cook a grenade" as popular in many action games. function Cook() { var power : float = powermin;

 while (Input.GetButton("Fire1"))
 {
     var move = speed * Time.deltaTime;
     power = Mathf.MoveTowards(power, powermax, move);

     if (autoThrow && power == powermax) 
         break;
     else 
         yield;
 }

 Shoot(power);

}

function Shoot(power : float){ var projectile = Instantiate(cannonball, transform.position, transform.rotation); projectile.rigidbody.AddForce(transform.right * power); Physics.IgnoreCollision(projectile.collider, collider); }

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image The_r0nin · Dec 16, 2010 at 10:58 PM 0
Share

What do you mean "How far the force is?" Do you want a line representing the magnitude of the force (easy). Do you want a projected intersect point on the plane? (easy if the plane is perpendicular or there is no gravity, more difficult if gravity is involved) Or do you want a curved path representing the path of the object (serious labor)? If you help, you need to be very clear about exactly what you want help with...

avatar image Dave M · Dec 16, 2010 at 11:11 PM 0
Share

Ok I mean a line representing the magnitude of the force.If I hold the mouse button the line goes up to $$anonymous$$ax.power on a plane or between two game objects.

avatar image Dave M · Dec 18, 2010 at 09:52 PM 0
Share

$$anonymous$$aybe somebody could help me, please ??

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

About Forces and Time.deltaTime 3 Answers

Trigger GUI working wrong 1 Answer

How to make a Keypad for a locked door 2 Answers

Add Force without Rotation 2 Answers

Impact Force Gui 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges