I'm not a complete newb, but I'm really stumped by this one. I have a game that uses a 3rd person controller and smooth follow camera script. The net effect, it that I have a world my character plays in that is full 3d, but the camera stays in sync with the character on his X & Y axis(NON ORBITING). In addition to this, I have a 2nd player on the screen who acts as a rover (rolling ball) who operates independently from the main character. My 2nd player is typically controlled by the right analog joystick of a PS3 or XBOX Controller. The control is driven by calling rigidbody.AddForce() on the ball itself. My problem arises when my levels do not have strict X & Y level design applied to them. It seems that rigidbody.AddForce() is relative to world coordinates and not current input direction.
Ideally, I would like to call AddRelativeForce based off of the the current camera rotation, but I'm really struggling with how to do that.
Anyone else ever have a situation like this?
I cannot visualize your setup. You say the camera follows on the X & Y (NON ORBITING), which implies there is no camera rotation, but you write of using the camera's rotation for adding your force. I think you need a diagram, or a short video, or something to demonstrate the setup. The solution is probably easy once the setup is clear.
Answer by iwaldrop
Jan 08, 2014 at 05:04 AM
You didn't post any code, and I agree with robertbu that it is difficult to tell exactly what you mean, but I think I may understand you, and it seems pretty simple. Use Camera.main.transform.left or its inverse instead of Vector3.left.
That worked for me, Thanks!
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
21 People are following this question.
pivot of CharacterController`s collider is not the pivot of the charcter????
How to remove mouse icon with character controller
Sliding down slopes on the Character Controller?
Roll a Ball - Video 7 error
Roll A Ball: Can't get ball to move. Did not make same error as earlier posters.