Change layouts when within range of a sprite

Get help using Construct 2

Post » Sun Feb 02, 2014 12:28 pm

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.Limmy422014-02-02 12:36:24
B
3
Posts: 5
Reputation: 210

Post » Sun Feb 02, 2014 4:45 pm

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
computer

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

Compare two values
distance(player.X,player.Y,computer.X,computer.Y)
<=
100
B
34
S
9
G
3
Posts: 517
Reputation: 5,226

Post » Sun Feb 02, 2014 7:47 pm

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.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,832

Post » Mon Feb 03, 2014 2:20 am

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.
B
3
Posts: 5
Reputation: 210

Post » Mon Feb 03, 2014 2:42 am

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.
B
3
Posts: 5
Reputation: 210

Post » Mon Feb 03, 2014 7:52 am

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
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,832

Post » Mon Feb 03, 2014 12:30 pm

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.
B
3
Posts: 5
Reputation: 210

Post » Mon Feb 03, 2014 1:52 pm

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Feb 04, 2014 7:35 am

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!
B
3
Posts: 5
Reputation: 210


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 15 guests