R0J0hound's Recent Forum Activity

  • That would work. Kind of what I was thinking. The only thing is mouse sensitivity makes no sense when clicking. At least to me. I’d expect where I clicked to be where I clicked.

    What behavior is the op trying to go for? He didn’t explain much.

    Sensitivity could work for click swipes.

    Global number px=0
    Global number py=0
    On left click
    — set px to mouse.x
    — set py to mouse.y
    Left mouse down
    — sprite: set x to self.x+(mouse.x-px)*1.1
    — sprite: set y to self.y+(mouse.y-py)*1.1
    — set px to mouse.x
    — set py to mouse.y

    I guess you could take that idea with mouse lock too.

  • Oh nice. I forgot about that one.

  • I don’t think I’ve made a complete example of that.

    Using the physics behavior with the path finding behavior kind of solves that. But it can be janky because the two behaviors fight with how the objects move. It’s slightly improved by setting the physics velocities to 0 every frame, but the behaviors are still at odds.

    To remove the fight you’d ideally just use the physics behavior to move, and not use the pathfinder for movement, although you would use it for finding the path. Basically you’d set the velocity to velocity+(targetVelocity-velocity)/10. Where target velocity is the velocity you’d want to go toward the next waypoint on the path. The /10 is to make it smoother, but isn’t frame rate independent as is. Then you’d just need to check if a waypoint was hit or no so it would move on the the next waypoint.

    The main issues here are not being able to reach a waypoint so it could cause things to get stuck.

    There is also a technique called steering behaviors (not actual C3 behaviors) or boids that I think could be useful here. The math above is basically steering, it changes the velocity till it’s facing a certain direction and velocity. Basically you’d find the paths, or since it’s many objects to one spot you could use dijkstra's algorithm to get kind of a flow field. Then you’d steer the enemies to move along the path, away from each other and walls, and in the average direction the enemies around them are going. A last step would be the physics to keep things from overlapping as a last ditch effort. Lighter than the physics behavior is one technique called verlet physics which has the benefit of inferring velocity from the previous position which could be useful here.

    To handle a high volume of objects using some kind of grid spacial partitioning would reduce the number of collision checks.

    In theory the enemy’s would the flow around the terrain while not overlapping each other.

    Anyways that’s just few rough ideas. Might attempt it later and see how much simpler an actual example would be.

  • Glad it was useful.

  • Here are two older ideas. I’m pretty sure they used a box as the collision shape but I think it could be updated to clip any collision shape by the water.

    construct.net/en/forum/construct-3/how-do-i-8/floating-physics-140019

  • One idea to avoid the trees being clumped too much is to use a single nextSpawn timer for all of them. That would let you specify the min time between trees. You’d just have to rearrange things so a random tree sprite is created.

    The other idea to only allow trees to be places so that it is actually possible to jump over is much harder. A rough idea would be to simulate the path of the player jumping and see if it can clear the trees and land. Might be able to simplify that with a calc of how far before a tree you have to jump and where you’d land after, then combine them somehow. Probably would need to add some tolerances to allow for reaction time and variance from the engine. Anyways could be a rabbit hole of ideas to try.

  • Is it just a straight line between A and B?

    If so you can limit another objects position between them with:

    T=clamp(((b.x-a.x)*(sprite.x-a.x)+ (b.y-a.y)*(sprite.y-a.y))/((b.x-a.x)^2+ (b.y-a.y)^2),0,1)

    X=lerp(a.x,b.x,t)

    Y=lerp(a.y,b.y,t)

    That formula is a vector projection.

    If the path isn’t straight then you’ll have a series of lines. For that you’ll need to incrementally find what line segment to limit the sprite’s position to.

  • Here’s one way. You can change the camera code but it relies on the forward vector which is only set by the look at action.

    One touch changes the camera and a second touch tosses a tomato.

    dropbox.com/s/cd5gad46nqx49sd/Tomato_toss.c3p.zip

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I mean there aren’t that many 3d features available in construct so trying to do anything beyond the obvious features will be more involved if possible at all.

    For example even throwing a tomato in 3d becomes an involved multi part problem. Construct doesn’t really provide anything that would make it easier.

    1. The tomato would need to be a sprite or a mesh. If a sprite you’d probably want to use a distort mesh so that you can have the sprite always face the camera. But only if the camera is set with the look at action. The camera rotate action makes it harder. Then if 3d there’s the problem of the limited number of 3d shapes. For that you’d either need a third party 3d plug-in, or do some trickery with distort meshes.

    2. To move the tomato we’d need to do the physics from scratch. None of the behaviors will help here.

    Off the top of my head the motion and basic ground plane collision detection would be this:

    Every tick
    — add gravity*dt to vz
    — set x to self.x+vx*dt
    — set y to self.y+vy*dt
    — set z to self.z+vz*dt
    
    Z<0
    — destroy

    To launch you’d set the starting z position, then set the velocity (vx,vy,vz) to the camera’s forward vector times some speed.

    Anyways as you can see there is math involved. And the names of things are different in construct. Like zelevation instead of z. Plus you’ll want to set the project z scale from normalized to regular.

    I know an example would be ideal but I feel like I’m re figuring out how to do it every time. As is it’s hard to just drop an answer without an example and have it be clear how to implement that into construct.

  • If you add a variable t to the pillar then you could do something like this:

    On bullet collides with pillar
    — pillar: set t to 0.5
    
    Pillar: t<=0
    — pillar: set y to self.y-50*dt
    
    Pillar: t>0
    — pillar: subtract dt from t
    — pillar: set y to self.y+75*dt

    With that it will go up at 50 pixels per second. Once it gets hit it will go down at 75pixels per second for 0.5 seconds. You can change all the values.

  • I agree it would be tedious to make the collision shape manually and it would be hard to get it to be smooth.

    But you can use mesh distort to make any shape you want. For example this takes a square sprite and makes it into a circle. Even with just 20 points it's decently smooth. Typically you'd make that invisible and put the sprite you want for a visual on top.

    dropbox.com/s/rxruw0ke7ox9uo5/collision_shape.c3p

    The second part of that example loads the outline of a mario sprite.

    You can use this tool to create the point list.

    dropbox.com/s/ldpsgtgzxwuajfc/marchingSquares2.c3p