Change layouts when within range of a sprite

0 favourites
  • 9 posts
From the Asset Store
Minimal Sprite Font with Stroke for Pixel Art games.
  • Hello, I'm very new here and I apologize if a thread like this already exists but I couldn't find it.

    What I am after is the player to only be able to switch to a different Layout upon pressing a button but ONLY when they are within a certain range of a sprite.

    In this instance I want to enter a new layout which is a computer console with buttons and such but the player can only access the computer (switch layout)once they are close enough to it and press the interact button, in this case the space bar. I don't want the player using the computer even though they are on the other side of the map. A work around would be the player having a little tablet type thing that can access all the computers at the press of a button (something I can do) but I would really rather only being able to use the computer when they are within a certain distance.

    I have searched the Googles and the forums but haven't been able to find anything, any help would be greatly appreciated.

  • You could use line of sight behavior and set that to what ever is the distance. This would automatically prevent interacting trough walls if they are set to solid.

    Had LOS to object


    Or you could use System expression "distance" something like this

    Compare two values




  • or place a (clear/empty/invisible ) sprite big enough to cover the area the player has to be standing and when the player is over this sprite activate the computer.

    or alter the console sprite to include a clear area in front of the console the player has to be overlapping.

  • I still don't quite understand, I added LOS behaviour to the computer sprite but what exactly am I supposed to do with that? I still can't interact with the sprite since when I set an event for the space bar it turns out like this:

    Keyboard-On Key Pressed-Set Space Bar as button

    and that's it, I have no idea what to put as the action to make it work.

    I need more steps in how to do your suggestions because it seems to me you only gave me half the answer and I'm back where I started.

  • Okay, so I have it so that my sprite can walk into the computer console and it will change the layout, so that's my fall back plan. Is there anyway that I can make it so that the player can only change layout when you are within a certain range AND you press a button.

  • this is how I would go about it - the pinkish area is where the player is close enough to the computer console is - obviously you would make this sprite invisible.

    press space when close enough to activate computer

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm currently downloading the beta version of Construct 2 so I can load that file you posted but I have no doubt that I'll be able to reverse engineer the file and I greatly appreciate your help.

    There is another thing I am having an issue with which really confuses me, I have a layout specifically for dialogue from a a character (Drone) where it is an image of the drown and when you press space the text changes. It works fine so long as I don't have more than two "Keyboard-on Space pressed-Set Text" events. At the moment I have three, the first text box is displayed which is not part of the events then when you hit space it skips to the last one instead of going through them one at a time.

    Unfortunately I do not have the rights to post a URL to a screenshot I took of the Event sheet. In its stead I want you to image three events that are all triggered to change the text when you press space. I also want you to imagine that the text that was absolutely hilarious, full of satiric wit that puts even Blackadder to shame.

  • Instead of posting a screenshot of youe events, you might be able to type them out for us.

    I think if you are using sprites for displaying the text it might be easiest to put them all in 1 sprite as animation frames.

    That way you could make an event:

    on space pressed - sprite set frame : sprite.frame + 1

    There could be a better solution than using images, however..

  • Thanks for the help, my game is coming along nicely and at this rate would be finished in a a couple weeks. I just wish I was better at the artistic side of things so I could make the game look pretty.

    Thank you all very much, because of this thread I should be able to finish the game!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)