A Physics doubt with speed and angle

0 favourites
From the Asset Store
3D Car Pack 1
$2.99 USD
3D models + Rendered Low-Poly Cars in isometric, top-down, and side angles.
  • Hello Everyone,

    Actually I am trying a basketball free throw 2d game. A simple character in the right, and the basket in the left end. My questions are...

    1. When I mouse click or touch in the screen, the ball should comes towards my clicking position.

    2. Based on how far and close I am clicking from the player, the ball should be fast and slow.

    Thanks in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have attached a rough example using the physics engine. When you click on the screen it will throw the ball towards your mouse, and the farther away you click the more force it will give the ball.

    Let me know if you have any questions!

  • Just downloaded.....Will check bro

    THanx

  • I missed one thing! Click on the ball and set the collision mask to "circle". Otherwise it will try to collide like a square and act a little silly.

  • THanx it what i need. BUt i cant figure out hot to set the Physics Force distance like you did

  • I used a simple distance calculation:

    distance(Mouse.X,Mouse.Y,Ball.X,Ball.Y)

    This will set the force directly to the distance from where the mouse was clicked (Mouse.X and Mouse.Y) to where the ball currently is.

    You can adjust this force by multiplying it afterwards if you want.

    Half the force: distance(Mouse.X,Mouse.Y,Ball.X,Ball.Y) * 0.5

    Double force: distance(Mouse.X,Mouse.Y,Ball.X,Ball.Y) * 2

  • Awesome n tanx

    Now I am trying it as a bullet. Created a simple canon and a bullet ball. Applied every actions to that bullet ball, but it is not working properly.

    HOW TO DO THIS -

    I want that canon to shoot a bullet with variable speed based on the distance of my mouse click.

  • If i remove the Physics force distance cmd and add

    "Bullet-->Set bullet speed to Mouse X" it works fine. When I keep my mouse close enough to canon and click, the speed is less and if i click far away from the canon, the speed is quick.

    BUT THIS IS ONLY FOR X

    Ok. If i add Y "IT IS NOT WORKING"

    Help me here Please...

  • Done Bro!!!!! Yes Found!!!!!

    With the help of this thread

    EgoAnt & caiorosisca Saved my day

    Thanks a lot

  • As I am testing in Mobile, when I change the mouse X and Y to Touch X and Y, the Bullet angle and speed does not work properly.

    Where ever I touch, I goes in the same speed.

    Why??

    Thanks in advance

  • Anybody help

  • Can you post your .capx file?

  • Here is your example from the other thread modified to work with touch. This has been tested on Crosswalk for Android.

  • Thanks a lot for giving a hand. I changed these same things but it didn't work for me.

    What did I miss?

  • EgoAnt Very interesting solutions. I made front hoops game for the place I'm working on. I had to "fake" perspective and stuff however I'd like to limit my bulit speed to stop it from going too fast. After all people can swipe preety fast but I dont want the ball to "go past the speed where you can't see it. Any ideas...?

    I'm attaching the current code in my game. It works but I'd like a bit of controll over the "max" speed of the ball so that it doesnt just go hyperspeed on me.

    Any ideas might help.

    I have a "shooter"at the bottom that moves side to side with a sine behaviour to make it harder for the player to aim exactly at the hoop which is on the middle of the screen. This is a "front view type hoops". I'm going on production tomorow but I'd like to iron out that issue for future updates to make it cooler.

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