- Home /
How does the premade FPSController handle character physics?
Hi, Im making a Portal-like game in Unity and I decided to use the premade Unity FPSController prefab for my character. I made a script that changes the rigidbody velocity of the object that passes thru one of the portals. The script works fine when using a normal object (I pushed a sphere with a rigidbody thru one of the portals and the ball thru out of the second portal with a correct velocity), but when my character passes thru one of the portals he becomes completely unaffected by the velocity change.
I noticed that the character uses both a character controller and a rigidbody(I have no idea how character controllers work). Does that have something to do with it? Why is my character prefab unaffected? Does anyone here have anymore insight on how the FPS prefab works or atleast how a character controller works? Thanks! (Im a Unity noob)
Without seeing some code, it's hard to tell.
I don't even know what do you mean by "velocity change". Is this basically preserving the player's momentum through the portals?
Basically you'd need to save the velocity of the inco$$anonymous$$g object into the portal, and apply that velocity to both instances of the object (one on one side, and one on the other side of the portal), to the best of my knowledge of portal mechanics.
Out of curiosity, what kind of approach are you taking to solving the portals problem? I myself had interest in doing a portal mechanics clone, which means both precise rendering of image through the portal AND seamless transitions. Googling around reveals that pretty much no-one actually accurately solved this, due to a deceptively large amount of work involved, both in physics department (cloning of objects that are inside portal's entry areas and duplicating controls and physics between them), and especially graphics (re-rendering of the scene from accurate angle to render texture, AND applying stencil rendering for solving the near-plane camera to portal clipping). It's basically the ultimate challenge.
@Eudaimonium Im not that interested in the portals visual parts. Im more concerned about the portal physics. $$anonymous$$y code looks abit like this: otherRigidBody.velocity = otherPortal.transfrom.forward * otherRigidbody.velocity.magnitude
(other = the object that has gone thru the portal) I basically want the rigidbody to keep its velocity but change direction to the direction the portal is facing. This works with all objects except for my FPSController prefab character and I dont know why!
Answer by kel12 · Oct 26, 2021 at 04:42 AM
hey man, im trying the same thing maybe check out this thread https://answers.unity.com/questions/1614287/teleporting-character-issue-with-transformposition.html I fixed the issue by going to Edit > Project Settings > Physics and turning on Auto Sync Transforms
Your answer
Follow this Question
Related Questions
Character Controller velocity match separate forward/backwards and left/right move speeds? 0 Answers
Best Strategy to interact with rigidbody 2 Answers
My player is stuck on left and right side(Endless Runner) 0 Answers
How to tell if the player is turning? 2 Answers
Help With Charchter Controller or Rigidbody . Please! 2 Answers