R0J0hound's Forum Posts

  • How? It’s all just algebra with the following equations:

    X=x0+vx*t

    Y=y0+vy*t+0.5*g*t*t

    Those have a lot of variables, so most you’ll assume you know the value of beforehand and you use algebra to solve for the unknown variable.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Construct wasn’t really designed with components like you describe in mind.

    As advertised it caters to non programmers with its layout editor and behaviors, with minimal use of events.

    Beyond that more advanced logic can be done with straight events. It’s a bit quirky in areas but any algorithm can be made with it. And in relation to your original question you can organize things with events but it’s not really modular enough to be be reused between projects. So you end up doing a lot of things from scratch every time.

    To make reusable stuff people end up using the sdk to make plugins and behaviors. JavaScript is mainly to tie in to third party libraries, or for performance reasons, or because people prefer it over using events.

    Overall construct wasn’t designed to do super structured code like Godot or unity. You can come up with ways to organize things with event groups and event sheets but it’s largely up to individual users.

  • I didn’t touch js because it’s not portable between c2 and c3. That and I just like straight events over using events.

    Anyways, I don’t use c3. look at the manual though. I think that js has a way to access event sheet variables. Perhaps that would be helpful.

  • You’ll have to parse the text manually. Here are a few ways but you can do simpler things too. I mean it sounds like you are already doing parsing, you just need to handle math expressions too.

    construct.net/en/forum/construct-3/how-do-i-8/perform-maths-expression-162865

    construct.net/en/forum/construct-3/general-discussion-7/visual-branching-passage-163824

  • Another way you can solve it is by time instead.

    T=1

    Vx=(x-x0)/t

    Vy=(y-y0-0.5*g*t*t)/t

    Which would make the object have a velocity where it would take 1 second to reach the target.

    A third way I attempted to calculate is to have a fixed speed and just vary the angle. However it gets more complex.

  • No trig is actually involved. All the math can be found with these two equations that define the path of a projectile.

    X=x0+vx*t

    Y=y0+xy*t+0.5*g*t^2

    Where:

    X/y is the destination

    X0/y0 is the start

    Vx/vy is the velocity

    T is the time

    G is the gravity.

    Anyways. You can solve that various ways. One is to just used a fixed vy and calculate vx.

    Vy=-200

    Vx=g*(x-x0)/(-vy+sqrt(vy*vy+2*(y-y0)*g))

    Anyways, that takes care of calculating the velocities. Just apply that to the movement behavior of your choice.

    If the behavior you want to use only lets you specify speed and angle of motion you can do this:

    Speed = distance(0,0,vx,vy)

    AngleOfMotion= angle(0,0,vx,vy)

    Finally if you apply that formula and the object just disappears the you go a NaN. Why? It just means it’s impossible to hit the target with the provided vy value.

  • Memory use is identical.

  • Yes, but none of it is portable to c3.

    There’s the paster plugin that has a action to draw a distorted quad.

    There’s a customDraw plugin that lets you do it too.

    You could even use the Rojo3d plugin to do it.

    There may be other plugins but I forget.

    Another way to to use the browser plugin to run some js to hijack the drawing of an instance and use the renderer’s drawQuad function directly.

  • Here's an updated example that lets you have separate bodies of water. It works by finding the neighbors with some overlap checks at the start of the layout.

    dropbox.com/s/lz8wz3g2lciurwv/spring_water2.capx

    Applying it to a distort mesh or drawing it with the canvas is something I'll leave to the users of c3. It should be straightforward.

  • Hi,

    Glad it’s been useful.

    If you set k2 to 0 the water is no longer connected to each other. So it needs to be greater than zero for they affect each other.

    The dt is indeed to make it frame rate independent. Basically it follows the formula: speed*time=distance

    It’s utilizing iids to access neighboring instances. So currently it works with only one body of water. I have a few ideas how to get multiple to work. One is to clone the object type for each pool and duplicate the events. Another is to store the iids in an array per pool to access neighbors. A third is to just use some instance variable that store the next and previous iid. Should be able to setup the last one with a loop at the start of layout.

    I’ll mess with that later today.

  • Here's one way to do it with springs. One spring to maintain a water level and two more to make the water level between two points match. You merely need to tune the spring forces and damping to adjust how it looks.

    dropbox.com/s/i894ii72hzpx8a9/spring_water.capx

  • Hi,

    There is no anti-aliasing done.

    To use a texture on a model there are two steps

    1. Load the texture from a file or sprite to a tag. The tag is to refer to it later.

    2. Tell an object to use a particular loaded texture. Should be an action under 3D appearance or something.

  • You probably could get better performance by reducing the number of instances of the plugin. But I guess it depends on what you’re doing.

    With the tags it’s just one per mesh. I was considering adding a group feature but I don’t have enough to time to implement it and test it without breaking things.

    When creating 3D objects you can copy another object so you don’t have to set up each attribute. But other than that there’s no way to change a bunch of objects at once without a loop.

  • That’s called “broad phase” collision detection. Basically doing approximate collision detections by using a distance check or something. Other ways are using bounding boxes, bsp, quad tree, collision cells, etc. construct already does it somewhat with the overlapping condition.

    Anyways you can do that with events but you’d have to actually do it and test if it improves performance. The overhead of implementing those things with events can often result in things being slower oddly enough.

    Anyways the logic of the distance check you describe could be:

    For each sprite

    For each terrain

    Compare distance between sprite and terrain <100

    Sprite overlaps terrain.

    But with events you already reduce the terrain loop by doing this instead:

    For each sprite

    Sprite overlaps terrain

    For each terrain.

    But that’s mainly because internally construct can filter the objects faster than you can do manually with events which are slower.

    You other idea of adding and removing objects as needed is another idea. But you’ll have to test it. This plugin was made so you only have to make events to update objects you want to move. All the static objects will just redraw fairly efficiently. Adding/loading on the fly would be slower but it may end up being faster in the long run. But you’d have to actually test it out.

  • I aim for simple and easy to read with my events if I can. Using arrays to store object info instead of sprites may or may not be better, it just depends on how you want to implement it.

    You can sort arrays, but you can also sort sprites with “for each ordered”, just use the stop loop action when loopindex=0 if you just want the closest. Or use a higher number to do stuff with more.

    The only time I use an array for terrain is if it’s in a grid formation, in which case a tilemap can work too for 2d. If the terrain is different sizes and whatnot I’d just use sprites.

    Not sure I grasp your distance calculation. Would a 3D distance calc work better?

    Sqrt((x1-x2)^2+(y1-y2)^2+(z1-z2)^2)

    I have no technical expertise with the fov behavior. I find behaviors seldom do what I want so I’m more inclined to do stuff from scratch than do things to bend behaviors to my will.

    For your last question I think there’s a misunderstanding.

    You get the position of objects with the x,y and z expressions as I recall.

    The orientXX/Xy...Zz expressions is the orientation matrix of the 3D object. Aka. How it’s rotated.

    You can think of those as three vectors.

    OrientXX/Y/Z is the left vector of an object

    OrientYX/y/z is the up vector of an object

    OrientZx/y/z is the forward vector of an object.