How do I make a sine sprite not overlap with tilemap & more

Get help using Construct 2

Post » Thu Sep 08, 2016 12:16 pm

Hey all! Basically I'd like to find a way for sine sprites to bounce off solids or tilemaps or collide with them instead of just moving through them. Is this possible? I created an jetpack enemy that patrols on the ground and starts to fly in the air when attacked. Sometimes he'll fly through the tilemap into another room or even off the layout. I have some other simple AI behaviors involving sines so I'd like to find a way for some sprites that have sine behaviors to not be able to go through solids or tilemaps. More importantly tilemaps. Thanks folks!
B
28
S
14
G
21
Posts: 179
Reputation: 13,548

Post » Thu Sep 08, 2016 12:25 pm

you added the solid behavior in TileMap? If yes and no work. Try adding behavior 8 directions in the jetpack.
Hi I am Samuel :)

My google play
B
39
S
10
G
1
Posts: 125
Reputation: 3,181

Post » Thu Sep 08, 2016 12:26 pm

Dont think you can do that in a good way with the sine behavior.

What you want is: On collission with platform/walls: move in a total other way then the sine behavior dictates.
Conclusion sine is not suitable to continue the new movement, can as well dig sine all thogeter.

Why not use the bullet behavior ? Let it bounce. Or give it a new direction 'on collission' ?
You cant let it go left and right based on the 'distance traveld'. Or change its direction when it overlaps invisible boundary objects.
B
33
S
18
G
28
Posts: 2,474
Reputation: 20,912

Post » Thu Sep 08, 2016 12:37 pm

99Instances2Go wrote:Dont think you can do that in a good way with the sine behavior.


Really the sine does not make much sense. The correct would be to use a behavior related to moving characters. :D
Hi I am Samuel :)

My google play
B
39
S
10
G
1
Posts: 125
Reputation: 3,181

Post » Thu Sep 08, 2016 12:55 pm

@99instances2G0 @martdsam Thanks for the quick responses! I did put a solid on the sprite. It would still go through the tilemap. So the idea was to create an enemy ai/pattern that looked like this.

Image

Here's my attempt.

Image

Sine seemed like a good idea at the time. I kind of like the way this works. I just wish the sprite didn't leave the layout or fly into other rooms. Also, the way the player "clicks" into the sine movement is a little jarring. Still, this was pretty easy to create and I think it makes for a semi-interesting enemy pattern. How would you guys recommend creating an enemy that would jetpack around in the air? I haven't tried giving this a bullet behavior to bounce off walls, will try that next. Thanks!
B
28
S
14
G
21
Posts: 179
Reputation: 13,548

Post » Thu Sep 08, 2016 1:12 pm

heyguy wrote:How would you guys recommend creating an enemy that would jetpack around in the air? I haven't tried giving this a bullet behavior to bounce off walls, will try that next. Thanks!


I'm creating a game that my main character has a jetpack. I use the behavior platform and 8 direction. When jumping it off the platform and use the 8 direction to control the character in the air.
Hi I am Samuel :)

My google play
B
39
S
10
G
1
Posts: 125
Reputation: 3,181

Post » Thu Sep 08, 2016 1:27 pm

@martsdam Thanks! How would I go about creating this sort of "random" flight pattern though. I can code a simple 8 dir enemy that moves in whatever certain direction but how do I create an enemy moves in this wild random flight pattern? This was the reason why I used a sine wave since I wasn't sure how to achieve it any other way.
B
28
S
14
G
21
Posts: 179
Reputation: 13,548

Post » Thu Sep 08, 2016 1:44 pm

What you want is: On collission with platform/walls: move in a total other way then the sine behavior dictates.
Conclusion sine is not suitable to continue the new movement, can as well dig sine all thogeter.

Why not use the bullet behavior ? Let it bounce. Or give it a new direction 'on collission' ?
You cant let it go left and right based on the 'distance traveld'. Or change its direction when it overlaps invisible boundary objects.


Thanks! Yes, this could all possibly work. I will look into this further. If I do go this route, the enemy behavior will change significantly than what I intended. I'm afraid that using a bullet behavior would be too complicated for me to create what I'm trying to create.

So I want the jetpack enemy to move back and forth around the player in a random-y sine type effect. Check out the gif above. I'm just not sure how I would be able to create such random movement without a sine wave. I cant imagine the combination of events and my math sucks. Having the enemy sine around in random pattern through bullet angle of motion math events sounds like a nightmare.
B
28
S
14
G
21
Posts: 179
Reputation: 13,548

Post » Thu Sep 08, 2016 2:37 pm

Check this out, heyguy. :mrgreen:

I don't think anyone has ever tried this method yet, but here goes. :mrgreen:

https://www.dropbox.com/s/43p5ojlsye06y ... .capx?dl=0
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Thu Sep 08, 2016 3:39 pm

@Gmoney OoOoh, very interesting. I like it! Great workaround to my problem. Just had a thought though, what if the player is near a wall and one of those colliders is inside a wall? The enemy would eventually sine into the wall and clip inside. It might get stuck if it disengages the jetpack. That's the only potential problem I see with this. Maybe. I'm not well versed in C2 to really know without trying. Could there be a workaround for this problem too? Something like if left of wall, then moveTo wall 2? I think any platform stuff gets ignored when sines are active though.

Either way, this is a really interesting idea and I'm sure I'm sure I can use it in dozens of other ways! Thanks!
B
28
S
14
G
21
Posts: 179
Reputation: 13,548

Next

Return to How do I....?

Who is online

Users browsing this forum: bluesun66, Kenthria, Malhog, plinkie and 1 guest