A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by blackbird_dream » Tue Nov 21, 2017 11:24 am
Newton in Unity is really great. Much faster/easier to handle than in raw C++ or Delphi progs.
My question is now : how can I get the velocity of a Newtonbody ?
something like GetComponent<Rigidbody>().velocity for a physxx rigidbody.
thks
-
blackbird_dream
-
- Posts: 354
- Joined: Wed Jun 07, 2006 3:08 pm
- Location: France
by Sweenie » Tue Nov 21, 2017 2:27 pm
I've added a Velocity and Omega property to NewtonBody.
By the way, if you are calling GetComponent<Rigidbody>().velocity inside the update function I recommend storing the component reference in the Start function instead.
It will be more efficient than calling GetComponent every frame.
Like this...
- Code: Select all
public class MyTestScript : MonoBehaviour
{
NewtonBody body = null;
// Use this for initialization
void Start ()
{
body = GetComponent<NewtonBody>();
}
// Update is called once per frame
void Update ()
{
if (body)
{
Vector3 vel = body.Velocity;
}
}
}
-
Sweenie
-
- Posts: 498
- Joined: Mon Jan 24, 2005 7:59 am
- Location: Sweden
by blackbird_dream » Tue Nov 21, 2017 2:30 pm
Thks so much Sweenie.
I'll test it tomorrow morning.
-
blackbird_dream
-
- Posts: 354
- Joined: Wed Jun 07, 2006 3:08 pm
- Location: France
by blackbird_dream » Wed Nov 22, 2017 5:35 am
Thks again.
I declared my script as a subclass of NewtonBodyScript
So I didn't need to declare
- Code: Select all
NewtonBody body = null;
Is it a problem regarding my previous question about sharing dll instead of sources ? I mean the script declaration
-
blackbird_dream
-
- Posts: 354
- Joined: Wed Jun 07, 2006 3:08 pm
- Location: France
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 13 guests