- Home /
Why multiply a vector by -2?
The code for the PhysicsCharacterMotor included with many of the example projects has this expression in the AdjustToGravity() method: Physics.Raycast(rayStart, transform.up*-2, out hit, 3.0f, groundLayers.value)
My linear algebra is very rusty so forgive me if this is obvious, but why would one need to multiply the up vector of the transform by -2, wouldn't -1 have the same effect (meaning down) assuming that the vector is only being used as a direction? Perhaps this was a mistaken attempt to move "past" the bottom of the character when starting the ray, but was never corrected when the more elaborate layer trick was employed as the code currently manifests?
Again, please go easy on me if this is a silly question. :-)
Answer by Eric5h5 · Jan 05, 2012 at 11:48 AM
Indeed, with a direction there is no reason to multiply by -2. It should ideally be written as "-transform.up".
Okay, thanks. Good to know there isn't some exotic trick being employed.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Click to move script help 1 Answer
Applying force with respect to angle with the ground? 1 Answer
Contextual Rose Menu not determining correct context. 2 Answers
How do I get one object to point toward another using rigidbody physics? 2 Answers