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

0 favourites
  • 11 posts
From the Asset Store
This is a black tileset with 2 tilemaps, props, one animated character and more.
  • 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!

  • you added the solid behavior in TileMap? If yes and no work. Try adding behavior 8 directions in the jetpack.

  • 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.

  • 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.

  • 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.

    Here's my attempt.

    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!

  • 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.

  • 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.

  • [quote:3tbw1f3n]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.

  • Check this out, heyguy. <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    I don't think anyone has ever tried this method yet, but here goes. <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    https://www.dropbox.com/s/43p5ojlsye06y ... .capx?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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!

  • You're always welcome, heyguy..!! <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    I would unpin the barriers once one of them hits the wall.

    Here's an example of the unpin method.

    https://www.dropbox.com/s/jvze67iehgwat ... .capx?dl=0

    The basic idea is to use those barriers on the side as bouncing points for just one flying enemy only.

    Once the enemy gets destroyed, then I would destroy the barriers at the same time and move on to the next enemy.

    Since the game's canvas is much larger than the (500,500) size used on the example capx file, the correct way of handling the unpin would be..

    1. Immediately unpin the barrier that hits the wall.

    2. Unpin the one didn't hit the wall.

    3. When the Player moves away from the wall, then pin again.

    I would use a variable for this method as well. For example..

    a. Dropped = 1 when the right side barrier hits the wall and unpins from the Player.

    b. When Dropped = 1 occurs, the left side barrier unpins at the same time.

    c. There should be another variable called DistanceFrom and it's set to Player.x's location after dropping the barriers.

    d. While Dropped = 1, when DistanceFrom becomes -50 or so, meaing Player's X moved away from the wall 50 in the amount of 50 pixels, then Pin those barriers again to the Imagepoint 1 and 2.

    4. This way, the Player will always have the wall while the Enemy is chasing and hovering above, even after hitting the wall.

    In order to prevent the enemy from chasing the Player forever and interfering with other enemies, I would..

    1. Set a variable of EnemyPosition and trigger only once to record Enemy's X and Y position when its line of sight activates.

    2. If EnemyPosition is bigger than a certain number of pixels, meaning the enemy was following the Player for more than that number of pixels (e.g. 350), then Enemy will lose line of sight and move back to the EnemyPosition.

    Just an idea, but they should work.

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