Hello everyone. I hate to be “that guy” who runs online to get code handed to him, but I’ve been trying to work this out all weekend, and I’ve gotten stuck in a rut, so I decided to finally give in and join the community, and maybe get some help from some of you fine folks out there. Please bear with me - I’m an artist, and I’ve never coded before in my life.
I need to have a very simple gameplay mechanic. The player enters a teleportation device that will put him on another wall, change the gravity, and rotate the play character accordingly.
So far, I have the teleportation and gravity switch working fine. This right here teleports the player to the next portal:
var destination : Vector3;
function OnTriggerEnter(who : Collider)
{
who.transform.position = destination;
}
And this changes the world gravity upon teleportation.
var x : float = 0.0;
var y : float = 0.0;
var z : float = 0.0;
function OnTriggerEnter (forceTrigger : Collider)
{
if(forceTrigger.rigidbody.name == "testRigidCube")
Physics.gravity = Vector3(x, y, z);
}
Everything works perfectly with a normal rigidbody box. I can send it through portal A, and it instantly comes out of portal B and falls whichever direction I want it to. The main obstacle I can’t overcome is to get these physics to cooperate with my rigidbody controller. Right now I’m using the RigidBodyFPSWalker from the unify wiki, but I’ve tried others, and none of them seem to work because everything uses world coordinates, I believe, to gauge the jumping the moving.
The best solution I have come up with is to have six separate rigidbody controllers (one for each wall) that each stick to their respective wall. I would then presumably switch between them all every time the player teleports. This is a clumsy, inaccurate solution, though - and I’m sure there has to be a simple way to rotate a character controller and make it respond to the updated world gravity.
Anybody help is greatly appreciated. I’ve been trying to modify code in the RigidBodyFPSWalker script for a few hours now, with little to no success.