playMaker

Author Topic: 'Teleport' Action[SOLVED]  (Read 1699 times)

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • View Profile
    • Rage Quit Games - Coming Soon
'Teleport' Action[SOLVED]
« on: October 09, 2012, 05:53:56 PM »
Someone wrote this script for me back when i first started working with unity and it still works well but i'd like a playMaker action.

If someone could write this it'd be greatly appreciated, add some more functionality if you like :)

Code: [Select]
var go_next_spawn_point : GameObject;

private var v3_next_spawn_point : Vector3;

function Start() {
    v3_next_spawn_point = go_next_spawn_point.transform.position;
}

function OnTriggerEnter(other : Collider) {
    if (other.name == "Player") {
      var go_Player : GameObject;
      go_Player   = other.gameObject;
      go_Player.transform.position = v3_next_spawn_point;
    }
}
« Last Edit: October 09, 2012, 10:36:49 PM by jeanfabre »

Red

  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Re: 'Teleport' Action
« Reply #1 on: October 09, 2012, 07:13:47 PM »
Actually, this is very easy to do without having to rely on a custom action...

the "set position" should work perfectly for what you need.

1. set up an idling state on the teleporter that uses a trigger event action that looks for the player entity.
2. when the player enters the teleporter, assuming you've stored the player's game object in a variable, you can then go to another action that will "Set position" of the stored object to the new coordinates.
3. a finish event that loops back to the idling state so it can be used multiple times or you can have it stay at that last state if you only want it to be a one-off.

i'll see about putting together a template or package if you would like some extra clarification.

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • View Profile
    • Rage Quit Games - Coming Soon
Re: 'Teleport' Action
« Reply #2 on: October 09, 2012, 07:20:55 PM »
I've found a way to do it with iTween using 'iTween Move To'

Thanks for explaining how to do it though :)