How do I make a sprite move (A-B) in a variable arch path?

0 favourites
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I'd like to move a ball with variable speed and arch angle, but it must always get from point A to B, then from B to A. Like a pong, but always hitting the targets (that are not moving, just the ball)

    Ive tried with bullet / gravity but sometimes it misses the target. When it hits the target I move bullet speed to -180. Ive added a small variation on bullet angle but it doesnt work.

    Could you help with ideas? Any easy way to do it?

    Thanks in advance

  • You could use and x an y tween using lunarray litetween behaviour:

  • well depends....you can try using the circular motion examples that uses sin/cos functions or the lerp function but then again depends what you want to exactly achieve. wold the ball rotate on both 360 degrees or just above? cause for above i have a capx that can help you, for bellow also the same but youl need to add some conditions to trigger the movement of the mid ball. and then you wont be able to use solids or anything else anymore. but you can add your own event system collision box so its ok either way. but with bullet you should be able to do it, using gravity, it only will need gravity adjustment based on the distance between A and B

    here is a circular movement AtoBcapx using the sin/cos

  • If you want parabola movement you could use the qarp() expression

    Var t=0

    Every tick

    --- set t to time%2

    --- set t to (t>1)?2-t:t

    --- set X to qarp(a.x, (a.x+b.x)/2, b.x, t)

    --- set y to qarp(a.y, (a.y+b.y)/2-variance, b.y, t)

  • If you want parabola movement you could use the qarp() expression

    Var t=0

    Every tick

    --- set t to time%2

    --- set t to (t>1)?2-t:t

    --- set X to qarp(a.x, (a.x+b.x)/2, b.x, t)

    --- set y to qarp(a.y, (a.y+b.y)/2-variance, b.y, t)

    that's neat "oh"

  • You could use and x an y tween using lunarray litetween behaviour:

    I'll install it, thanks!

  • well depends....you can try using the circular motion examples that uses sin/cos functions or the lerp function but then again depends what you want to exactly achieve. wold the ball rotate on both 360 degrees or just above? cause for above i have a capx that can help you, for bellow also the same but youl need to add some conditions to trigger the movement of the mid ball. and then you wont be able to use solids or anything else anymore. but you can add your own event system collision box so its ok either way. but with bullet you should be able to do it, using gravity, it only will need gravity adjustment based on the distance between A and B

    here is a circular movement AtoBcapx using the sin/cos

    Thanks, dude. This capx is a pretty good way to do it.

    The objective I want to achieve is like one person kicking the ball to the other, without letting it fall. For it not to be boring, I will random part of the speed, simulating a stronger kick. But I gotta find a way (if using bullet) to make a formula that would adjust gravity vs speed so it can always aim and hit the target.

  • Thanks, dude.

    no problem, however R0j0hound's formula is much better just change the 250 number i added in the capx where is the variance or the curvature point.

    r0j0hound A to B QARP movement

    you could use instead of the 250 number distance(pA.x,pA.y,pB.x,pB.y)/2 feels more natural.

  • If you want parabola movement you could use the qarp() expression

    Var t=0

    Every tick

    --- set t to time%2

    --- set t to (t>1)?2-t:t

    --- set X to qarp(a.x, (a.x+b.x)/2, b.x, t)

    --- set y to qarp(a.y, (a.y+b.y)/2-variance, b.y, t)

    Genius.

    I must confess I've never studied this qarp expression before. Getting the C2 manual now. Thanks!

  • >

    > Thanks, dude.

    >

    no problem, however R0j0hound's formula is much better just change the 250 number i added in the capx where is the variance or the curvature point.

    r0j0hound A to B QARP movement

    Yeah! you guys did it. I tried using sine movement on A and B and it works as well. Fantastic.

    Thanks again!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I tried using sine movement on A and B and it works as well

    you could'v drag the A and B point by hand forgot to tell you that! my bad

  • > I tried using sine movement on A and B and it works as well

    >

    you could'v drag the A and B point by hand forgot to tell you that! my bad

    Haha, no problem. I noticed that.

  • I noticed I should find a way to reset the sequence from a certain point.

    I mean, if i touch the screen, soccer player will go frame 1 (kick) and if it is colliding, he must kick the ball to the other side. Problem is, that ball will always go forward until it touches A.x A.y. Is there a way to interrupt it earlier? like if the ball has hit a wall?

  • Hi my name is Jazz813 and I have some troubleshots about my little project. First of all let's start from the beginning of my problem, I want to create a Game & Watch like game, I can move the player but in 5 differrent Layouts and here comes also my problem, here a picture from my game so maybe everyone can make a better image of the problem.

    So my problem is that when I move my player from left or right the birdscrap will disapear when the next frame jumps to the next Layout what's logical, I also tried to work with more Layer in one Layout because I think that if everything plays in one Layout it should work, but also there I encouted problems and it's when I tip it in the event sheet that the Player will move when I press the left or right button from the keyboard for example, it work for one frame but maybe I don't know the option to do it so , but I can't say the programm that if I press the left button anew the player move to the left agian and the last picture disapear...

    Could anyone help me on this problem ?

    Thanks very much

    Jazz813

  • Hi my name is Jazz813 and I have some troubleshots about my little project. First of all let's start from the beginning of my problem, I want to create a Game & Watch like game, I can move the player but in 5 differrent Layouts and here comes also my problem, here a picture from my game so maybe everyone can make a better image of the problem.

    So my problem is that when I move my player from left or right the birdscrap will disapear when the next frame jumps to the next Layout what's logical, I also tried to work with more Layer in one Layout because I think that if everything plays in one Layout it should work, but also there I encouted problems and it's when I tip it in the event sheet that the Player will move when I press the left or right button from the keyboard for example, it work for one frame but maybe I don't know the option to do it so , but I can't say the programm that if I press the left button anew the player move to the left agian and the last picture disapear...

    Could anyone help me on this problem ?

    Thanks very much

    Jazz813

    Hey dude, I think you should create a new topic.

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