Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
How to add a force 90 degrees / sideways from a forward vector3 direction

I have 2 cubes, one big, one small, the larger cube will be stationary, while the smaller cube will be given a force towards the larger cube with :

smallerCube.GetComponent<Rigidbody>().AddForce((largeCube.transform.position - smallerCube.transform.position).normalized * force);

now I want to find out how to add a force with a 90 degree offset on the Y axis from the above given direction

largeCube.transform.position - smallerCube.transform.position

so it will seem to orbit the largerCube with a force towards it as well as a sideways force with a 90 degree offset from the 'towards' direction.

how would I go about doing something like that, using Rigidbody physics.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You rotate a vector by simply multiply it with the according rotation using the * operator.

For an offset of 90° in the global Y axis you can use Quaternion.Euler like e.g.

var rotatedDirection = Quaternion.Euler(0, 90, 0) * (largeCube.transform.position - smallerCube.transform.position).normalized;
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!