How To Send A Signal When Character Above A Certain Y Value?

Discussion in 'How Can I...?' started by CGSciFi, Jul 23, 2020.

  1. CGSciFi

    CGSciFi Boxer

    Joined:
    Oct 9, 2018
    Messages:
    6
    Likes Received:
    0
    I’d like to trigger the enemies into action when my player character goes above a certain height...y value. Inversely I’d like the enemies to stop when dropping below this value.

    My first attempt used a planeas a collision object that sent a signal to the enemies. This half works but I don’t know how to then disable the enemies when passing back down through the plane.

    I don’t see a simple ‘if’ node that checks an assets position.

    How would I script this?

    Many thanks....from a new boxer :)
     
  2. mohamed awad

    mohamed awad Avid Boxer

    Joined:
    Mar 10, 2019
    Messages:
    280
    Likes Received:
    150
    you can get asset position using
    this.entity().position()
     
  3. CGSciFi

    CGSciFi Boxer

    Joined:
    Oct 9, 2018
    Messages:
    6
    Likes Received:
    0
    Thanks so much for your reply.
    I'm new to JS so implementing this is proving tough.
    I tried customising the 'limit position' node etc as a starting point to understanding it. I think my logic is close but my lack of JS formatting knowledge leads to a lot of errors thrown.
    Basically I want a node that says...

    IF character Y position is greater than 10 then SEND signal.

    Sounds simple but several full days later I'm still nowhere as scripts have to be so perfect.
    Anyways thanks for the bone above, I'll keep trying :)
     
  4. mohamed awad

    mohamed awad Avid Boxer

    Joined:
    Mar 10, 2019
    Messages:
    280
    Likes Received:
    150
    on character Y
    if(this.entity().position().y > 10){
    DO.........
    }
     
  5. mohamed awad

    mohamed awad Avid Boxer

    Joined:
    Mar 10, 2019
    Messages:
    280
    Likes Received:
    150
    If you confused about DO........
    What kind of signal do you want to send?
     
  6. CGSciFi

    CGSciFi Boxer

    Joined:
    Oct 9, 2018
    Messages:
    6
    Likes Received:
    0
    Thanks so much for your help. I just want to send a regular signal like the premade 'send' node.
     
  7. mohamed awad

    mohamed awad Avid Boxer

    Joined:
    Mar 10, 2019
    Messages:
    280
    Likes Received:
    150
    add output
    add this line on update function
    if(this.entity().position().y > 10){
    this.emitSignal ('ouput name' , true);
    }
    this will give you an output signal
    but it's updating signal so if you want to limit it you have to set some variables
     
  8. CGSciFi

    CGSciFi Boxer

    Joined:
    Oct 9, 2018
    Messages:
    6
    Likes Received:
    0
    So in the case of a default ‘send’ node I should change ’output name’’ for ‘something’.... is that correct? Thanks
     
  9. CGSciFi

    CGSciFi Boxer

    Joined:
    Oct 9, 2018
    Messages:
    6
    Likes Received:
    0
    Any chance you can show me what this one line script node looks like when actually finished so I can understand what I’m aiming at. The default blank script node is full of functions that I’m not sure whether I need to enhance or ignore. Thank you so much :)
     
  10. mohamed awad

    mohamed awad Avid Boxer

    Joined:
    Mar 10, 2019
    Messages:
    280
    Likes Received:
    150
    no, it's an output signal,on the right list under node name
    if you want to set Send and receive node
    if(this.entity().position().y > 10){
    Event.fire('event groub' + 'event name' , true);
    }

    event group and event name are the send and receive attributes
     
    Josh (Nology Games) likes this.
  11. CGSciFi

    CGSciFi Boxer

    Joined:
    Oct 9, 2018
    Messages:
    6
    Likes Received:
    0
    Thanks again, I’ll try to implement this.
     

Share This Page