Trouble getting bike to work with physics

squallsquall Member Posts: 2
edited November -1 in Working with GS (Mac)
Hey everybody,
I'm working on making a bike that acts like a real bike. The back wheel is the "player" because it pushes the bike. The frame is constrainted to it. The front wheel is contrained to it. At this point, I can control the bike with keys 1 and 3 on the numberpad. The problem is the frame and the front wheel won't collside with the ground. They just also stay horizontal while the back wheel works great. How do I get the frame and front wheel to act normally? I need the front wheel to spin when it rubs on the ground and go up when it hits a hill.

I've uploaded a screenshot and the project files into: http://redsquall.net/gamesalad/

Thanks in advance for your help!

Comments

  • DrGlickertDrGlickert Member Posts: 1,135
    Do you have collisions on the front wheel?

    How do you have the front wheel and frame constrained to the back wheel?

    Also, I wouldn't use 1/3 on the num pad because not everyone has a num pad (like me). So I would have to change your behaviors to play the game. Try using A/D or the Left/Right arrow keys. ;-)
  • DrGlickertDrGlickert Member Posts: 1,135
    I can't open that project file you're using. Try putting it into a .zip instead of a .rar.
  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
    It may work better if the frame was the actor, and the wheels were constrained to the frame with collision detection. It's hard to get it to look right. I have a motorcycle game Im messing around with, and I couldn't get the constrains to look right, they kept overlapping when movement happened, and shifting around on the constrain points it looked like. So I just used a whole model of a bike, and had the spokes blurry so it doesn't look too cheesy, because the wheel aren't moving.

    Good luck, if you can get it to look right, I would love to see it.
  • AsymptoteellAsymptoteell Member Posts: 1,362
    You can't have collisions with constraints to x and y positions. Constrain the front wheel's position x to the (cos(angle of the bike)*(magnitude(bike height, bike width))/2+bikeposition.x. Do the back wheel with bike.position.x-cos(angle of the bike)*(magnitude(bike height, bike width))/2. Then make both of their y's bike.position.y+ sin(bike rotation)*(magnitude(bike height, bike width))/2 if their position.y>bike.position.y. Otherwise, bike.position.- sin(bike rotation)*(magnitude(bike height, bike width))/2
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    I dont think yo will be able to do this. I have tried several times to get a car to work the same way. The problem is the constrains override collisions if they ever conflict with each other. so getting the right combination of constrains is something I haven't figured out yet. You almost have to constrain the frame somehow to both wheels and not constrain the wheels to anything. but I really don't think its possible and if it is figured out I have a feeling the number of constrains and rules it would take will kill performance. If you do figure it out please let us know. I have a shelved game concept that I would love to complete.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    yeah your alot better off just making the bike one actor and then just haveing animations for the wheels going forward and back.
  • AsymptoteellAsymptoteell Member Posts: 1,362
    I have a demo for this coming. If you give me your email, Ill send you a beta incomplete version.
  • ChaserChaser Member Posts: 1,453
    This is what I'm working on http://gamesalad.com/forums/topic.php?id=17422#post-132451 but I chose not to constrain the wheels and such due to the unnatural collisions and when the bike goes upside down it starts to screw everything up. It may be possible with some math functions and constrain y every .2 seconds or something like that so the wheels and frame respond at different rates. Good luck! I'm considering selling my multi vehicle physics minus graphics after I submit the app so keep your eyes on the look out.
  • AsymptoteellAsymptoteell Member Posts: 1,362
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    @Asymtotell

    tenrdrmer(at)yahoo.com
  • Marc_n_SophMarc_n_Soph Member Posts: 111
    Hi, I tried all sorts of stuff to get this to work, and ended up taking the easy way out and creating a long flat "collider" actor (invisible) the length of the bike to collide with the ground, creating another "bike gfx" actor for bike and rider gfx, and constraining position of gfx actor to the position of the collider actor. I got pretty good movement with this (admittedly simple) solution!

    Vid here



    If I can help in any way, feel free to contact!

    Thanks for reading

    Marc n Soph
  • squallsquall Member Posts: 2
    Asymptoteell said:
    You can't have collisions with constraints to x and y positions. Constrain the front wheel's position x to the (cos(angle of the bike)*(magnitude(bike height, bike width))/2+bikeposition.x. Do the back wheel with bike.position.x-cos(angle of the bike)*(magnitude(bike height, bike width))/2. Then make both of their y's bike.position.y+ sin(bike rotation)*(magnitude(bike height, bike width))/2 if their position.y>bike.position.y. Otherwise, bike.position.- sin(bike rotation)*(magnitude(bike height, bike width))/2

    Asymptoteell - interesting. I tried this exactly as you said. It acts quite odd. It wasn't clear from your post what this would do exactly - what should it do? Do you mind taking a look at it? The only thing in the project is the bike and some ground to test it on. Press 1 and 3 on number pad to move left and right (that's temporary controls).
    Here's the link: http://redsquall.net/gamesalad/paperbike test aymptoteell.gameproj.zip
    Thanks Guys
Sign In or Register to comment.