Vector3 Global and Transform Local?

Ok, I’m probably missing something really obvious here, but I can’t figure it out for the life of me. I’m trying to give an instantiated object a velocity of 3 on the ‘y’- and 3 on the ‘z’-axis. By this I basically mean a local Vector3(0,3,3). However, adding this rule makes it have that velocity in World Space only:

rigidbody.velocity = Vector3(0,3,3);

And I know I can use this for a Local axis velocity:

rigidbody.velocity = transform.forward * 3;

But once I do that I can’t access the transform.up component of the vector anymore… As I was typing that I realized I could probably get away with this:

rigidbody.velocity += transform.up * 3;

and I could. =) However, I’d still like to know if there’s a way to give an object a ‘local velocity’ in one go. I feel this is sort of hacky.

Thanks in advance,
Patrick

From the docs:

“Transforms direction from local space to world space.”

So:

Vector3 worldVel = transform.TransformDirection(new Vector(0,3,3));

rigidbody.velocity = worldVel;

Not tested, but I’m pertty sure that will work.

EDIT: That said, to be “physics safe”, you should do it this way in FixedUpdate()

rigidbody.AddForce(worldVel, ForceMode.VelocityChange);

Hey Bren, thanks for your answer! It’s definitely a cool function I missed, but it’s giving me some weird results. As is, it makes the object’s velocity go backwards if I fire it from a 90 degree angle. When I change it to (0, 3, -3) it goes backwards when I fire it from a 0 or 180 degree angle. o.O
Also, what do you mean by Physics Safe? o.o I figured .velocity would be enough, as it’s a once-time occurrence (performed in the object’s Start() function). I assumed AddForce would be more suited for projectiles and the such. (In my case, it’s a mine that needs to be ‘shot’ out with a very low force, then fall to the ground and stay there.)