playMaker

Author Topic: I wanted to create a teleportation, I went crazy  (Read 740 times)

yardvolt

  • Playmaker Newbie
  • *
  • Posts: 6
I wanted to create a teleportation, I went crazy
« on: March 21, 2022, 08:03:21 PM »
Hello,
I'm trying to create two teleport triggers, "tp1" and "tp2".
My project is in 3d.

The goal is for my character to activate the triger from tp1 and move on to tp2. Then once crossed it activates tp2 to return to tp1.

If I create a state for tp1 go tp2, it works well but if I add a state for tp2 go tp1 it does not work, I have tried many ways, and I have always a similar result :/



First method:
- Create two cubes
- Activate trigger in the collider.
- Create 2 global variable vector3.


(This template in each of the two cubes.)

Tp1 Detected
-Trigger event (on trigger)
-Collide tag (player)

Tp1 actived
-Get Key Down (send event : Move to Tp2)
- Trigger Event (on trigger exit)
collide tag (player)
send event (Back)

Move TP2
- Set Position
(Game object : Player)
Vector (global variable)
Space (world)
-Wait
(0)
Finish event (RESTART)

So far not working, or only 1 teleporter, but now yes will understand why ..., on the other hand I assigned a key to restart the level, and if I restart it it no longer works.
 
Second method :

- create two cubes
- activate trigger in the collider.

(For those I created the template in a single FSM, it worked, but my player was trapped in an endless teleportation loop, I tried to add elements like: trigger exit, wait, Get key down , but without success, the template no longer works.
So I split this template in two as in method 1, where each finds in cube 1 and 2.)




Detected
-Trigger event
game obj : (cube1)
Trigger (on trigger stay)
collig tag (player)
send event : (move to)
Store collider (variable game object)

Move to TP2
-Get position
game obj (cube2)
Vector (variable vector3)
space (world)
-Set position
Game obj (variable obj)
Vector ( variable obj)
Space (world)

here too the transitions go well and turn, but no teleportation, and sometimes it works, for no particular reason. :'( :'( :'(

Now 5 min after this post without having modified anything, it works in infinite loop version, I don't understand anything anymore, I wonder if it's not unity that has a problem, or me who is creating a bug with a bad setting .

And finally the last method

- create two cubes
- activate trigger in the collider.
- Create 2 tag for cube.
- I create only 1 FSM on player.


Detect trigger
- Find game obj
With tag (cubetag1)
Store (variable obj)

- Find game obj
(...)cube2

- Get position
Game obj (variable obj)
vector(variable vector3)
Space(world)

- Get position
(...)cube2

- Trigger event
Gobj (use owner)
trigger ( on trigger enter)
collide (cube tag)
send ( Tpx Detected)
- Trigger event
(...)cube2

Tp1 Detected
-Get key down
send event (Tp player)
-Trigger event
Trigger (on trigger exit)
collide ( cube tag)
send (back)

Move to tp2
- Set position
Gobj ( use owner)
Vector ( variable vector3 other cube)
Space (self)
Here works very well if I only have: TP1 DETECTED and MOVE TO TP2 in my FSM if I add TP2 DETECTED and MOVE TO TP1, the transitions are played but the teleportation of the player does not work.
So for a one-way teleportation it's perfect but not for a double one.



If someone has the courage to read this, and can explain to me where I'm wrong, because I think I tried everything ^^

Method 1 works apparently, it just doesn't work anymore when I restart level from the game via a key, I don't know why.
« Last Edit: March 21, 2022, 08:15:24 PM by yardvolt »

yardvolt

  • Playmaker Newbie
  • *
  • Posts: 6
Re: I wanted to create a teleportation, I went crazy
« Reply #1 on: March 21, 2022, 08:23:45 PM »
Ok I think Unity is trolling me, now all teleporters work, but in their own way:

Method 1:
Works if I don't use method 2 or a restart of the level.
Method 2:
works if I don't use method 1, on the other hand works after restart of the level.
Method 3:
 infinite loop.
« Last Edit: March 21, 2022, 08:25:36 PM by yardvolt »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7623
    • jinxtergames
Re: I wanted to create a teleportation, I went crazy
« Reply #2 on: March 22, 2022, 04:09:15 PM »
Hi.
I did not go thru all of your explanation, but here's my take on it

tp 1 :
when used (how you use it can be your own way triggers etc)
if you want it to persist after a game session, Save a bool (set to true) 'Tp1 Activated' (playerprefs or easy save)

tp 2 :
When used : before doing teleport, load the bool 'Tp1 Activated'
then do a Bool Test if it was activated or not