How to trace at detail a trajectory on a canvas

0 favourites
  • 6 posts
From the Asset Store
Game for kids for tracing letters. A simple game for tracing letters.
  • Hello,

    I am shooting a bullet up at -45 angel and let it fly with gravity and am plotting a parabola of its trajectory on a canvas.

    at every tick i am creating 1 pixel line at the location of the bullet -- and it indeed traces the flight path -- however, i notice that the trace is discontinuous -- many disconnected dots in particular as the bullet accelerates further ...

    Is there a way to actually create a smooth path -- looks like the redraw algorithm is more detailed than each tick.

    thanks,

    Dan

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can enable stepping in Bullet properties, and use "On Step" event to draw dots - this will create 5-10 more dots per tick. You can also draw lines between dots.

  • Thanks!

    I will check out the stepping.

    I didn't want to "fall back" onto drawing lines because it would take away from the smoothness of the curve and hence its "real" nature

  • Looks like physics and bullet have overlapping functionality -- i like gravity that it enables creating an impact force ... which bullet doesn't have ...

    But, only bullet has on step ...

    oh well ...

  • Yeah, don't use Physics with other behaviors like Bullet.

    You probably need to interpolate a curve between points, maybe R0J0hound could help you with this.

  • A curve drawn with lines is smoother than you think. It's just a matter of resolution.

    dropbox.com/s/9a76a3nx6od06nr/drawtracerexample.c3p

    Edit: If you don't want to use drawing canvas, using a sprite object as a line connecting the current position to the last position will work mostly the same. Use distance(x,y,lx,ly) to set the width, and angle(x,y,lx,ly) to get the angle.

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