teleportation?

Discussion in 'Programming' started by Tales, Aug 14, 2019.

  1. Tales

    Tales Member

    Joined:
    Apr 11, 2018
    Posts:
    44
    Hello!

    I need to "teleport" a objetc. BUT :

    -without destroy/recreate it
    -without use x=xxx because there is other objects between 2 points and it dont works
    -without changing room and rechanging room

    I tried things like "action_set_relative(1) action_move_to, move toward point" but dont works because of all others object in the trajectory (and "action" seems deprecated) ..

    I dont know all function in GM, I search but if there is someting..

    (maybe its not possible to "teleport" item?)
     
  2. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    1,969
    In general, you set an instance's position by setting its x and y value. It can be more complex but something as simple as:

    Code:
    
    if (condition) {
        x = new_x;
        y = new_y; 
    }
    
    
    would work. If you're not using x and y for position, you'd set whatever you were using instead.
     
  3. Tales

    Tales Member

    Joined:
    Apr 11, 2018
    Posts:
    44
    it dont works, it seems the object GO to the position, but there is things on the trajectory, so it dont works. Its not a "teleportation" :s
     
  4. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    1,969
    Are you using physics?

    Otherwise, setting an instance's position is completely unconnected to a trajectory. I do it all the time and the above does work. Make sure to post the code you do have and have tried.
     
  5. Tales

    Tales Member

    Joined:
    Apr 11, 2018
    Posts:
    44
    no i dont use physics!

    Exactly the same code, instead of x=xxx; y=xxx, i do

    room goto (teleport room);

    and when in teleport room

    room goto (the room I need)
    x=xxx; y=xxx

    and this works.. But I dont want to have a room only to "teleport"..

    EDIT : it seems there is really something interfering because I move all object between the 2 position, the character dont move at all.. I dont know why "x=xxx:y=yyy" dont work...........

    thanks for responding I guess I keep teleport solution..
     
    Last edited: Aug 14, 2019
  6. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    1,969
    If you setting the x and y variables directly and going there then you would have something interfering.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice