Physics Tools Extension (Beta Release 4)

rodolfovs

  • *
  • Posts: 183
how can I create a trajectory such that identifies collision with actors and tiles, but without angle, straight parallel to the actor? As this game https://www.youtube.com/watch?v=AqpWUOEQ6x0

How could I do this without downloading this extension, because I tried to install and could not

merrak

  • *
  • Posts: 2738
Hi,

If you want to detect actors and tiles in a straight line, the Raycast API would be more appropriate. The Physics Tools Extension takes gravity and velocity into account.

I didn't see the Raycast API on the developer's market, so it may not be current. The original thread is here: http://community.stencyl.com/index.php/topic,16734.msg241226.html#msg241226

rodolfovs

  • *
  • Posts: 183
Thanks @merrak, I just install the extension and go test. You have used this extension? I do not quite understand the operation of it.

merrak

  • *
  • Posts: 2738
For what you described, use the "all actors on line from x,y to x,y" block. This will return a list, so set up a list attribute. Then you can loop through all the actors in the list and handle them however you need to.

rodolfovs

  • *
  • Posts: 183
Thank you! I will do my attempts

Rainbros

  • Posts: 175
Great looking extension! (Haven't used it yet, but I'm sure I'll be needing it sooner or later.) I was just wondering, would it be possible to draw a curved trajectory as a line of evenly-distributed points? I.e., make the distribution of points based on arc length rather than time?

merrak

  • *
  • Posts: 2738
Great looking extension! (Haven't used it yet, but I'm sure I'll be needing it sooner or later.) I was just wondering, would it be possible to draw a curved trajectory as a line of evenly-distributed points? I.e., make the distribution of points based on arc length rather than time?

I'm imagining a lot of integral calculus :o

It should be doable. The input is number of seconds because Box2D models motion in discrete time steps (0.01 second increments in Stencyl). This means the formula the extension uses is a function of number of steps, and so requires that input. I don't see an obvious way around that constraint.

One thing you could do, though, is get a formula for the parabola that is drawn--which would be a quadratic. Write it as a quadratic function of the x coordinate. If you want your dots spaced evenly horizontally, that would be simple with the function. Getting the dots evenly spaced with respect to both dimensions would be more challenging. The only solution I can think of right now would be to use the arc-length formula to evenly divide the arc itself into equal-sized segments. Then you can place at dot at the edge of each segment.

colburt187

  • *
  • Posts: 2416
Hey Merrak,

would I be able to draw the predicted path of my golf shot using this extension, the power is a constant but the angle can change, Ive attached an image of my launch ball logic.

LIBERADO

  • *
  • Posts: 2720
would I be able to draw the predicted path of my golf shot using this extension, the power is a constant but the angle can change,

<a href="http://static.stencyl.com/games/35170-0.swf" target="_blank" class="new_win">http://static.stencyl.com/games/35170-0.swf</a>

« Last Edit: September 07, 2016, 06:50:14 pm by LIBERADO »
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

merrak

  • *
  • Posts: 2738
Hey Merrak,

would I be able to draw the predicted path of my golf shot using this extension, the power is a constant but the angle can change, Ive attached an image of my launch ball logic.

Looks like Liberado got to this before I had a chance to. So, yes :)

The marching dots effect is pretty cool, but I am noticing some lag. I wouldn't suggest using 1000 iterations. You can stop the arc when it collides with a tile using the arc raycast tool. Keep in mind that it will suffer from the same pitfalls as the standard raycast when it collides with tiles/terrain.

colburt187

  • *
  • Posts: 2416
Awesome, going to play with this now

LIBERADO

  • *
  • Posts: 2720
I am noticing some lag. I wouldn't suggest using 1000 iterations.
The Behavior never uses 1000 iterations, it uses a few tens of iterations only, those that are strictly necessary to draw the visible path. Please, don't let yourself be confused by the "1000" number. It is only an anecdotical number. If you analyze the algorithm you will realize that the "exit loop" block always stops the loop after using a few tens of iterations. I get 60 FPS constantly in Flash, HTML5, Desktop and Android. If you notice some lag, it is not due to my Behavior, I can assure you that it is highly efficient.

You can stop the arc when it collides with a tile using the arc raycast tool.
:) Yes, I know, but for a better understanding I have shown a simple example. It is simple and efficient in terms of performance. (Performance is always the most important factor for me.)

« Last Edit: September 08, 2016, 07:45:34 am by LIBERADO »
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

colburt187

  • *
  • Posts: 2416
Thanks this is working well. Awesome extension Merrak and awesome example Liberado.

Bhoopalan

  • Posts: 1018
The tool looks so awesome!! Thank you so much merrek.
If I helped you at anytime, help me back build my twitter followers :)
https://twitter.com/imbhoopalan

merrak

  • *
  • Posts: 2738
The Behavior never uses 1000 iterations, it uses a few tens of iterations only, those that are strictly necessary to draw the visible path. Please, don't let yourself be confused by the "1000" number. It is only an anecdotical number. If you analyze the algorithm you will realize that the "exit loop" block always stops the loop after using a few tens of iterations. I get 60 FPS constantly in Flash, HTML5, Desktop and Android. If you notice some lag, it is not due to my Behavior, I can assure you that it is highly efficient.

 :) Yes, I know, but for a better understanding I have shown a simple example. It is simple and efficient in terms of performance. (Performance is always the most important factor for me.)

You're right--I missed the exit loop. It turned out I had a different runaway process in the background, and the demo must have been the straw that broke the camel's back.

I really need to move this tool out of beta. It's been out for a while and I'm not aware of any newly discovered bugs.