SOLID: Force mouse sprite to bounce/NOT pass?

0 favourites
  • 13 posts
From the Asset Store
Bouncing ball
$9.99 USD
Template for a bouncing ball game, fully documented in comments and video
  • Hope you can help.. I'm obviously a newbie..

    Here is my problem:

    I have a mouse controlled sprite character (i.e. lets call it 'maincharacter'). I move the mouse controlled character around the screen using the mouse. That works fine.

    I have an egg in the center of the screen. I do NOT want the mouse controlled character to pass over the egg. Instead, I want it to be forced to go around the egg. I would prefer that it would 'bounce' off the egg... but at this point, I CANNOT figure out how to PREVENT the mouse controlled character from going over egg in the center of the screen.

    How the heck do you do this?

    I DO have both the mouse controlled character with the behavior of 'solid.'

    I DO have both the egg in the center of the screen with the behavior of 'solid.'

    I DO have it play a sound when the mouse controlled character 'collides' with the egg..   so it does know when the 2 objects are colliding... but I cannot figure out how to prevent the mouse controlled character from NOT going through/over the egg..   I basically want the egg in the center of the screen to act as a WALL... nothing should pass through the wall... everything has to go around the wall/egg.

    How the heck do I do this? Please be as specific/detailed as possible. I'd be grateful. :)

    Note: I tried to post a link to my event sheet, but since I"m a newbie, it won't even allow me to do this! :(

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In what way do you control the character with your mouse?

    Drag and drop?

    set bullet towards mouse?

    pathfinding to mouseclick?

    probably would be helpfull to know to be able to give an answer.

  • Here is a picture of my event sheet.. since this website won't allow me to provide the exact link, I just put spaces in it.. but hopefully this will show you EXACTLY what I did:

    http: // puzzele.com / construct2 / question1.jpg

    PS: I know it is a LOT to ask, but if its easier, perhaps you can create a really small sample program for me.. and I can take a look and see EXACTLY how you did it.   My email is: puzzele gmail . com

    I'm using the free version of construct2..   

    PS: If its easier to see EXACTLY what I was trying to create, you can take a look at the game I already made... but I'm hoping Construct2 will make things easier in the future -- although I'm not so sure yet:

    http: // puzzele.com / datingsite / videogame / IdoNOTwantKids.exe

  • Well... this makes NO sense to me, but I've tried everything... about the best I can do is assign the behavior MOVEMENT '8direction' to the egg in the center of the screen -- just to prevent the mouse controlled character from going through the egg in the center of the screen. Once I do this, then the mouse controlled character does NOT go through the egg... unfortunately, however, the egg does NOT stand still.... Instead, basically the egg in the center of the screen gets moved around when the mouse controlled character hits it.

    Call me crazy... but there should be a VERY simple way to have two objects touch/collide without all these problems. Any suggestions?

    At a minimum, it seems stupid to me and illogical to assign '8direction' MOVEMENT to the egg in the center of the screen (just to get it NOT to MOVE/prevent other characters from going through it -- which makes NO sense)... anybody know how to prevent the egg from getting moved around after other items hit it? This does not seem to happen when the other items such as 'bullets' touch it... but once the mouse controlled character touches the egg in the center of the screen, the egg moves. Hopefully I'm missing something.. but this seems waaaaaaaaaaaaaay too confusing for something so basic.

    Again.. all I was trying to do was have an egg graphic sit in the center of the screen and NOT move when other objects hit it and/or prevent the other objects from going through it...   but this does NOT work when the object hitting it is controlled by the mouse.

    Any info would be enormously appreciated.

    Incase you did not see the graphic above (since this website does NOT let me post links since I'm new -- again making things more difficult/aggravating), here is what my event sheet looks like

    System -- Every tick -- mousecontrolledgraphic -- Set X to Mouse.AbsoluteX

    System -- Every tick -- mousecontrolledgraphic -- Set Y to Mouse.AbsoluteY

    And again, ALL of my graphics have the characteristics of 'solid' including the egg graphic sitting in the center of the screen.

  • Solid doesn't work this way. It works in combination with certain other behaviours.

    a simple first way to set this up would be:

    mouse cursor is not over egg - set mousecontrolledgraphic to mouse.x,mouse.y

    but this wouldn't make the graphic go around the egg

    another way would be to give the graphic bullet behaviour and set it's direction to mouse.x, mouse.y. set the bullet behaviour to bounce of solid and it will work.

    another way would be to give the graphic drag and drop behaviour and mak it drop on collision with the egg..

    another way..

    well there are so many ways, but it all depends on what you are trying to do.

    you might want to take a look in the manual to see why solid behaviour isn't working the way you think it should work. It was not meant for what you are trying to achieve.

  • LittleStain: Thanks soooooooo much for your response and trying to help. Unfortunately, after screwing with this program for another hour, it still does NOT work. :(

    Your first suggestion: mouse cursor is not over egg - set mousecontrolledgraphic to mouse.x,mouse.y   <-- as you said, this wouldn't make the graphic go around the egg so I skipped it.

    Your second suggestion: give the graphic bullet behaviour and set it's direction to mouse.x, mouse.y. set the bullet behaviour to bounce of solid and it will work. <-- I did exactly that. I made both the egg and mouse controlled graphic solids. I also made both have the bullet property. I also said yes to bounce off of objects for both. Here is a copy of the worksheet:

    System -- every tick -- mousecontrolledgraphic -- Set position to (mouse.x, mouse.y)

    However.. the same exact thing happens... I can control the mouse controlled graphic, but it STILL goes through the egg. It does NOT go around the egg.

    Hence..   and please do NOT take offense because I am sincerely grateful for your help, it still does NOT work.

    Is there any way possibly you can simply create the tiny construct2 program and email it to me? It will only require 2 graphics (one that you move with your mouse, and the other in the center of the screen representing the egg).. All I want is the mouse controlled graphic to NOT pass through the egg in the center of the screen.

    Sincere thanks again.. but so far, I simply CANNOT get this program to do something as simple as have two objects not pass through each other....   this is NOT a promising start. Many thanks.

    PS: And IF we can ever solve the first problem of not having the graphic pass through the egg, here is a second question:

    I want the mouse controlled graphic to start in a specific spot on the screen (towards the bottom). How do I do that? I don't seem to have any control about where EXACTLY to 'start' the mouse controlled graphic.

  • This works.

    dl.dropboxusercontent.com/u/403350/egg.png

    add a 8-dir to the player character

    add solid to the egg

    every tick - player -> rotate 2 degrees towards (mouse.x, mouse.y)

                 player -> move 1 pixel at angle (angle(player.x, player.y, mouse.x, mouse.y)

    it will constantly walk towards the mouse as it moves around, and bump up against the walls of the egg without overlapping.

    see my example file.

    dl.dropboxusercontent.com/u/403350/egg.capx

    is that what you want?

  • I think you are looking for something more like this, but it will take some work to get it to do exactly what you'd like.

    SpriteAround

    Events:

    <img src="https://dl.dropboxusercontent.com/u/48563442/SpriteAround/SpriteAround.png" border="0">

  • LittleStain:   Thanks soooooo much for continuing to try and help me.. I SINCERELY appreciate it. :)   And PLEASE PLEASE PLEASE PLEASE do not take offense, but this is how I see it:

    1. As for the SprintAround you posted in your most recent above message...   I personally found it very complicated. Maybe I'm a schmuck but commands such as "Set Y to lerp(sprite.Y,sprite2.BBoxTop,0.5)" is very very very confusing to me -- particularly when all I'm trying to do is have two solid objects NOT pass through each other. Even worse, I noticed that if you use your mouse QUICKLY, you can still get the round ball to pass through the square in this example. Hence, its still NOT working correctly despite it being complicated.

    2. Your example file that you made at dl.dropboxusercontent.com/u/403350/egg.capx seemed to work much better.. and is a heck of a lot easier to understand.. although I still found the command a bit confusing. Even more confusing is I notice that if I keep the mouse still (don't move it), then the mouse controlled graphic shakes a bit. Why? Again, I'm soooooooooo confused as to why and wasn't able to figure out a way to not have it shake. Hence, I still can't get construct2 to work correctly.

    I honestly cannot thank you enough for your ongoing help.. It is SINCERELY appreciated.... but do you think there might be an easier way to do this?   I'm new to Construct2, but to me, it seems the programmers really need to make such a simple task a LOT easier to do. For example, I previously used Multimedia Fusion. In that program, you simply tell the two objects to 'bounce' off each other if they touch. That simple <- one event that is sooooooo easy to understand that even I could do it. No formulas. No nothing. You simply check off the boxes and pick something like, "If object A" "hits objects B" then "bounce". The end.

    Anyway.. let me know if you have any other suggestions.. I'd very much prefer to use construct2 in the future because of the ability to export without having to pay extra.. but at least to me.. this single task of having 2 objects not pass through each other (which just so happens to be the very first thing I tried to do), seems incredibly complicated.

    Hopefully I'm missing something.... Again, many many thanks for your ongoing help. It is sincerely appreciated.. If nothing else, I've learned that there is no 'easy' way to have the two objects not pass through each other...   :(

    If you have any other suggestions, PLEASE do let me know.. but to me, it seems waaaaaaaaaaaaaay too complicated for this simple task.

    PS: Here is what I made:

    puzzele.com/test/index.html

    But again, the egg does NOT stand still when it is hit. I can't believe there isn't an EASY way to get the egg to not move around the screen when something hits it and/or prevent something from going through it. And again, not to pick on construct2, but personally, I find it very confusing/illogical for me to have to assign '8direction' MOVEMENT to the egg in the center of the screen (just to get it to prevent other characters from going through it -- which makes NO sense)...

    I'm hoping the programmer of Construct2 will read this message and possibly revise the program accordingly to make it easier to use in the future. I realize Construct2 is a very powerful program and can do lots and lots of things.. but seriously..   me trying to have two objects simply bounce off each other shouldn't be soooooooooooooooooo complicated. It literally was the very first thing I tried to happen in my very first game using Construct2. :(

  • Ok let me try to explain why what you want to do isn't easy..

    You want the sprite to be at mouse.x, mouse.y all the time, except when the mouse is overlapping the egg.

    So you are going to have to tell the sprite what to do when the mouse is overlapping the egg. This is the hard bit, because you want it to follow the mouse, but it can't because the mouse is overlapping the egg. So you have tto tell the sprite how to follow the mouse, without overlapping the egg.

    if you want to click somewhere and have the sprite go there you can use the pathfinding behaviour and it will go around the egg no problem.

    But you choose to have the sprite at the mouse, so it's pretty hard to tell the sprite what to do when that is impossible.

    So If you can find a simple way to explain in normal language where you want the sprite to be when the mouse is overlapping the egg and how to react when the mouse is no longer overlapping the egg, maybe than there is an easier way to explain it to the computer too.

  • BTw: the egg.capx was from justifun and not me.

  • Any Good ?

    edit - Basically the same as justifun s but using bullet behaviour. Variable ball speed to make it go faster the further it is from the mouse and slow to a stop over mouse. Ball speed will cut to zero on contact with the egg to stop bounce.

  • ive got the same problem, but with all of the walls im trying to use.. i cant for the life of me find a solution.. with the mouse cursor actually being that responsive...

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