[8486-sem+título.png|8486]
I’m making a free running/parkour game like mirror’s edge and one of the best ways I can think of is making 3 triggers on the player, one on left, one on right, and one on front of the character, my character is a rigidbody btw, I want to add probably one script for each trigger, to call something like this:
function OnTriggerEnter (col : Collider)
{
if ( col.gameObject.tag == "wall")
sendMessage ("WallRunRight")
}
but how do I send a function like this to my main script? and then On my main script I would have like a function o tell what that function does? Or you think it’s better this way?
var MainPlayer : gameobject;
var WallRunningRight : boolean = false;
function OnTriggerEnter (col : Collider)
{
if ( col.gameObject.tag == "wall")
WallRunningRight = true
}
and then on function update I would use something like this;
function update ()
{
if (WallRunningRight)
MainPlayer.rigidbody.useGravity = false; // then I'll add some force to decal down over time, but tell me wich way you think it's better or even if none of these would do a good work
}
edit: ok it is kinda working I tried the second one but it’s giving me some problems, Idk Why but when I jump during left wallrun it goes more far than if I jump while right wallrun, and when I’m in right wall run and pressing “D” to go against wall it jumps to the left as it should, but if I’m on a left wall run and press A against the wall and then jump I jump to the wall instead and that will let me jump multiple time since I don’t go away from the wall. Take a look at my scripts please: WallRunLeft - Pastebin.com, it’s the main script, right wall run script : WallRunRight - Pastebin.com and left wallrun script: WallRunLeft - Pastebin.com
Dude! These 3 sripts are amazing! I've been editing them for the past few days and it works like a charm! You're awesome at coding!
– RPMonkey