How would I make a radar system?

Hello, I would like to make a system that will start to flash if you get close to that actor... how would I do this? Thanks :)

«1

Comments

  • bjandthekatzbjandthekatz Orlando, FlMember Posts: 1,375

    This should be achievable with the magnitude function. If you cant find out any information on it, I will try to make a template.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @bjandthekatz if I remember clearly I believe I saw a video of how to do this... but for some reason I can't find it anymore.

  • SocksSocks London, UK.Member Posts: 12,822

    @http_gamesalad said:
    bjandthekatz if I remember clearly I believe I saw a video of how to do this... but for some reason I can't find it anymore.

    It's really straightforward . . . (two actors, Hero and NME).

    In the hero actor place a rule that says . . . . .

    If magnitude ( self.X - NME.X , self.Y - NME.Y ) is less than 200 (or whatever)
    --Then do your flashing code/animation here.

    This bit magnitude ( self.X - NME.X , self.Y - NME.Y ) measures the distance between the two actors.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @socks I believe you might have left out some crucial information.. this is what I have set up in my my main actor Image and video hosting by TinyPic
    & this is what I have set up in my radar actor Image and video hosting by TinyPic

    It isn't working.. does this seem right to you? Thanks :)

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2015

    @http_gamesalad said:
    It isn't working.. does this seem right to you? Thanks :)

    Hard to say really.

    I can see that you are changing the NME values just once, and the Radar actor is moving, therefor the red Main actor will be taking its measurement from where the Radar actor was when the NME X and Y value were recorded. Maybe they should be constrains ? But like I say it's hard to say as I don't know my way around your game.

    Also I don't understand and why in the Main actor the rule checks to see if the distance from the Radar is less than 200 - if it is less than 200 then the rule changes the distance to the distance !? Can you explain what the rules are doing ?

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @Socks before I came on on the forums I found this video .. someone said it involved magnitude. I'm not trying to achieve a blast effect I'm trying to achieve (but without the tables.)

  • SocksSocks London, UK.Member Posts: 12,822

    @http_gamesalad

    before I came on on the forums I found this video . someone said it involved magnitude. I'm not trying to achieve a blast effect I'm trying to achieve (but without the tables.)

    I don't know what that means, did you see my previous post ?

  • http_gamesaladhttp_gamesalad Member Posts: 1,340
    edited June 2015

    @Socks this is causing more confusion (so please forget I brought this in). So could you tell me what rules I should put to achieve the radar please? :)

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2015

    @http_gamesalad said:
    So could you tell me what rules I should put to achieve the radar please? :)

    Sorry I can't do cyclic one way conversations, they are far too mysterious for me ! :smiley: I hope you get it sorted out, it's a fairly straightforward task, best of luck.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @Socks its straightforward for you because you know how to do it. If I know how to do this I wouldn't be on the forums asking for help with this problem. You left out some information.. for example .. in the change attribute behavior _set: ????????? to:magnitude ( self.X - NME.X , self.Y - NME.Y ) is less than 200 (or whatever) _ . I have no clue what to put in the "set" part of the behavior.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    but instead of trying to help me solve this issue you just leave me hanging ... how I'm I supposed to learn? The point of this forum is to get help for coding you can't understand & growing your knowledge... so less people will come back on here asking for help.

  • SocksSocks London, UK.Member Posts: 12,822

    @http_gamesalad said:
    Socks its straightforward for you because you know how to do it.

    Agreed, anything we are familiar with seems straightforward, but it can appear to be more complicated than it actually is if we've not familiarised ourselves with the process.

    @http_gamesalad said:
    If I know how to do this I wouldn't be on the forums asking for help with this problem.

    Agreed.

    @http_gamesalad said:
    You left out some information..

    What is 4+4 ?

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2015

    @http_gamesalad said:
    but instead of trying to help me solve this issue you just leave me hanging ...

    Not at all, I've attempted to engage you in a conversation specifically aimed at resolving your issue, but you've ignored my questions ! lol :smiley:

    Instead of answering my fairly basic questions you just "leave me hanging" ! :wink:

    @http_gamesalad said:
    how I'm I supposed to learn?

    By engaging with people who are interested in helping you solve these issues.

    @http_gamesalad said:
    The point of this forum is to get help for coding you can't understand & growing your knowledge...

    Agreed.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @Socks I brought in > @http_gamesalad said:

    Socks before I came on on the forums I found this video .. someone said it involved magnitude. I'm not trying to achieve a blast effect I'm trying to achieve (but without the tables.)

    In hopes of helping you understand why the "distance from blast" attribute was there. I saw that this was causing more confusion than helping. I don't mind deleting everything & starting from where you tell me to start. Because honestly that "distance from blast" attribute is very irrelevant (because that method didn't work) :). Thats why I said

    @http_gamesalad said:
    Socks this is causing more confusion (so please forget I brought this in). So could you tell me what rules I should put to achieve the radar please? :)

    Do you understand now?

  • ChunkypixelsChunkypixels Member Posts: 1,114
    edited June 2015

    @http_gamesalad I think @Socks is really trying to help you out, but you just need to give more details. Your probably best just starting from the beginning again, but giving some very specific information.

    Im currently implementing a radar system in one of my own projects, so I might be able to chip in and help. Im assuming its a flat overhead map your looking at, that the radar corresponds to?

    At what distance from your player actor do you want the target actors to register on the radar and start pinging?
    (So you can switch on/off the pings)

    How large is the Radius of your Radar Screen that you are displaying?
    (So you can calculate the ratio of radar blip on the radar circle compared to the distance between the object and target)

    Does the Radar need to factor in Rotation?
    IE: players orientation (forward view) on the map rotate, or is it always fixed to the same direction?
    (So you can work out if you need additional funky code to work out placement/rotation of the radar blips on the radar circle, in relation to the positions on the overhead map)

  • ChunkypixelsChunkypixels Member Posts: 1,114
    edited June 2015

    Ive attached a template that gives you a basic Radar based off an enemy distance and angle from the player. Control the player by using the arrow keys on your computer, and the radar should trigger a blip when you get within 200 pixels of the Enemy.

    The radar is based on the distance (magnitude) and angle (VectorToAngle) between the Player and the Enemy, divided by 2, as the Radius of the Radar display circle is 100 pixels, thus a ratio of 2-1 for distance on the play area compared to the radar circle.

    https://dropbox.com/s/e2228qdrih16g5m/Chunkypixels%20Radar_template.gameproj.zip?dl=0

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @Chunkypixels & @socks

    @chunkpixles I followed the rules exactly like you have in project file but it isn't working.. Here are my rules set in my main actor
    Image and video hosting by TinyPic

    & my radar
    Image and video hosting by TinyPic

    What I'm trying to achieve is if the main actor is very close to the radar actor the back ground will start to flash (flash yellow to 1)

  • SocksSocks London, UK.Member Posts: 12,822

    What is 4+4 ?

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @socks 21

  • ChunkypixelsChunkypixels Member Posts: 1,114

    @http_gamesalad its difficult to tell what exactly your doing/or not doing compared to the working template.

    Firstly...your working with the PC version, something I'm not overly familiar with, as I do everything GameSalad on a Mac. Secondly your screenshots don't appear to show all your actors code... so can't tell if theres additional stuff not being shown or missing.

    You'd really need to put up a template with your code, for us to look at and compare, in order to work out whats not working, or if your even doing the same thing as in the Mac template I provided.

  • ChunkypixelsChunkypixels Member Posts: 1,114

    @http_gamesalad Ive taken the previous Template into the PC version of GameSalad and made an updated template with a yellow flasher placed over the radar circle, that activates and flashes when the enemy is within 100 of the player.

    The rules for the flashing actor are all inside it (Radar Flash Yellow)

    https://dropbox.com/s/mwjay3hl7rdz4t0/Chunkypixels%20Radar_template_v2.zip?dl=0

  • http_gamesaladhttp_gamesalad Member Posts: 1,340
    edited June 2015

    @Chunkypixels Image and video hosting by TinyPic
    Image and video hosting by TinyPic

    game.ObjectDistance to Magnitude(Enemy X-PlayerX,Enemy Y-Player Y)

    For some reason it till isn't working. Here is the code set up. What I'm trying to achieve is when the main actor is less than 100 px away from from the enemy the background will flash bright red. I deiced to display game.ObjectDistance & it says I'm 600 - 700 pixels away from the enemy which makes no sense because my main actor is right next to it.

    The actor label "radar" I meant to set it to "enemy". Does this help you? Thank you very much :)

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    Also I'm spawning multiple enemy actors (If that helps you) :)

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @chunkpixels I was playing around with your template you gave me & I put multiple enemies spawning at the same time as my game set up & I saw it was having a very hard time keeping track of them. Maybe that's why my game isn't working because I'm spawning so many at a constant rate. @socks Do you think this is something you can help out with :)

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    You need to seperate all the actors. It's better if you monitor the distance the enemy is from the main actor not do it from the main actor.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @The_Gamesalad_Guru What do you mean by "separate all the actors"? & I switched the actors constrain & rules around like you said. So now what was in the Enemy Actor is now in the Main Actor & what was in the Main Actor is now in the Enemy Actor. It's still displaying game.ObjectDistance from 600-700 while the main actor is right next to the Enemy actor.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited June 2015

    i suspect you are tracking them all together as they are the same actor and you have them reporting to one set of attributes? If so that's not going to work. If all you want to happen is something to flash red when any enemy is within 200 pixels do this. Have you main actor send it's position to two game level attributes. Then have the distance calculation done in each enemy actor. And send the distance to a self attribute in each enemy. Then have a rule that monitors that self attribute in each enemy that triggers the flash. This will give you a basic flash trigger system.

    If you want to have a full fledged radar you will need to build a mini map type system and with that each enemy needs to be tracked individually aka each enemy needs to report their position to a set of game level attributes. I have a video on creating a mini map that uses scene linking of attributes. To do this type of overall system you want it would be best to do reycling of actors instead of spawning and use scene linking (I have a video on that too) as it requires less game level attributes. It seems like you're trying to code a system you're not quite knowledgable enough to grasp. Have you ever watched my GS logic series? It seems you need more study to understand how to build this as it is a bit complex but totally doable if you gain more understanding of how tracking attributes work.

  • ChunkypixelsChunkypixels Member Posts: 1,114
    edited July 2015

    Yup.. as the Guru said...you would need to track distance and position for each enemy you spawn and want to track within the radar zone.

    So would need an objectdistance and positionX and positionY attribute for each enemy...

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @Chunkypixels @The_Gamesalad_Guru could you please tell me how I would be able to do this? If you could

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited July 2015

    @http_gamesalad said:
    Chunkypixels The_Gamesalad_Guru could you please tell me how I would be able to do this? If you could

    Yeah I'd be typing for an hour. This is something you need to study. As I said watch my video on scene linking and watch my video on making a mini map and then find a video ,probably Jamie or GShelper, on recycling actors. From this information you can get info on how to assemble the logic you need. As I said, this is very complex logic. You're just going to have to put in some study time.

Sign In or Register to comment.