Pin sprite if overlapping another sprite

Just started using Construct 2? Post your questions here

Post » Sat Mar 08, 2014 1:42 pm

In my top down game I am trying get enemies to be pinned to the player at a specific image point, when an enemy is overlapping the player boundary box and a key is pressed. Using an instance variable, pressing the same key will unpin the enemy from the player.

Not sure what I am doing wrong. Example in the capx below:

Overlap_Pin_Test.capx
You do not have the required permissions to view the files attached to this post.
B
2
Posts: 5
Reputation: 160

Post » Sat Mar 08, 2014 2:18 pm

I have checked your work and found that you are trying to pin object point HOSTAGE to player. I cant see where is your hostage image point. work that one out and you be fine. You could use image animation frame number
B
249
S
39
G
15
Posts: 1,952
Reputation: 40,579

Post » Sat Mar 08, 2014 2:31 pm

After pinning the enemy to the player I'm trying to position the enemy sprite on the HOSTAGE image point which is the name of an image point on the player default animation (only has one frame).
B
2
Posts: 5
Reputation: 160

Post » Sat Mar 08, 2014 2:45 pm

No it should be on enemy because you are trying to pin enemy and not player
B
249
S
39
G
15
Posts: 1,952
Reputation: 40,579

Post » Sat Mar 08, 2014 2:54 pm

OK, leaving aside the image point, I'm still finding that the enemy won't pin to the player. I'm disabling the enemy bullet behavior before pinning to the player, but the enemy sprite won't stop moving. So I think there is something wrong with my event/function call.
B
2
Posts: 5
Reputation: 160

Post » Sun Mar 09, 2014 1:00 pm

It's working but you straight away turn it off again - event 5 calls the function and pins it correctly but event 6 straight away stops it. You can test this by changing the key required in event 6 from "E" to another key ("R" ?).
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 » Sun Mar 09, 2014 6:03 pm

Thanks! Need to use the same key for toggling the pin behaviour so have added an if/else to set a boolean,
B
2
Posts: 5
Reputation: 160

Post » Sun Mar 09, 2014 6:58 pm

Coming back to my original issue, I can't get the enemy to attach to a specific imagepoint on the player. I am using set position on every tick to the imagepoint X, Y co-ordinates, but this doesn't seem to work. Any suggestions?
You do not have the required permissions to view the files attached to this post.
B
2
Posts: 5
Reputation: 160

Post » Sun Mar 09, 2014 7:11 pm

So when it overlaps but before you pin just move it to the correct point
You do not have the required permissions to view the files attached to this post.
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


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests