vee41's Forum Posts

  • At least the spawning problem seems to be caused your layout scaling, instead of 'Scale' you should use 'letterbox scale' or similar, take a peek at layout scaling stuff at manual/soem tutorial. Seemed to solve the problem for me at least. I'd imagine the wrapping issue might be caused by this as well.

  • Could you have invisible `collision` sprite pinned to it with position only?

  • For debugging I use chrome log plugin, it simplifies a lot of stuff :-)

    It should not matter if two b instances are destroyed at same time, do you use on destroyed trigger? Posting a capx would allow us to help with this.

  • You could use plugin like easytween or moveto for good looking slide effect, or you could do one yourself with lerp function for example. Those plugins make it really easy so I recommend getting them from plugin forum here :-)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Boolean is usually easier to read and makes projects easier to manage, I use them if applicable. I also prefer strings over number states: "walking", "running", "crawling" is 100x easier to read than 1,2,3- describing states.

  • Say you have three objects in a layout. Lets say one is a (slowly moving) bullet type object headed towards a target object. A third object is invulnerable to the 'bullet' and wants get between the bullet and the target to intercept, or block, the bullet and protect the target. How could one achieve this in C2?

    So far I am using the custom movement behaviour for the 'blocker' object for other purposes, so a solution using that would be best.

    Here is my pseudo code solution, but I don't know how to do this in C2?

    * Find the bullet nearest to the target (in case there are more than one)

    * Find the point of intersection between the line between target and bullet and the shortest line between the blocker and this line ( I hope that makes sense)

    * Set angle of motion of blocker to that point

    * Set the speed of the blocker to as fast as possible (limited by an instance variable of the blocker)

    Note that this doesn't anticipate the bullet's motion, so isn't the most optimal solution for the blocker to save the target, but it would be a start.

    I can't find the required information in order to construct a (complex!) expression that could be used to set the blockers angle of motion. How do I determine the location of the closest bullet? The location of the target I can do.

    I know C2 is supposed to be 'programming free' but is it possible to in expressions to create temporary variables in some way? I need to set the blockers angle of motion, but first I need to work out the point to set the motion towards, then do some trig to get the angle. This would be a mighty ugly site as a single expression, even if I could find the required raw numbers to put it together. If I could insert a small 'script' in place of the expression that would be clearest.

    Any ideas?

    * Find the bullet nearest to the target (in case there are more than one)

    (Assuming there is one target)

    Bullet Pick Nearest To Target.X, Target.Y

    Bullet is now picked (check the FAQ thread to see what that means) and you can do stuff with it, like store it's location

    * Find the point of intersection between the line between target and bullet and the shortest line between the blocker and this line ( I hope that makes sense)

    Use Distance(target.x,target.y, bullet.x, bullet.y) to find the distance between bullet and the target, then use mathemagic to take accelarations, speeds and whatevers into account and create a formula to find the desired target X,Y location.

    * Set angle of motion of blocker to that point

    Custom movement (probably) has 'Set angle of motion' action, use Angle(Blocker.x, blocker.y, targetLocation.x, targetLocation.Y) to set it towards your calculated point.

    * Set the speed of the blocker to as fast as possible (limited by an instance variable of the blocker)

    Custom movement (probably) has 'set speed' action to do this :)

  • Thanks vee41, with trigger once it works as expected. It shows the numbers from 2 to 12 once on the screen.

    <img src="http://www.colarion.com/construct2-test/strange_for_loop2.jpg" border="0">

    Anyway I'm really wondering in what situation you could need the For-Loop to runs to eternity and not only once from 2 to 12?! It seams without Trigger once to be unusable?!

    Many situations! :)

    Here is an example project which uses for loop each tick to determine RTS units course of action:

    Sidescrolling RTS example

  • Yes, that was my theoretical expectation too!! But... in real C2... I just would like to write out the numbers from 2 to 12 on the screen. Sorry, maybe I don't understand the C2 programming logic. It would be realized that way with a common programming software. Please try this at home. No key press, no touch, no mouse.

    Place 'trigger once' or other trigger to your event. Otherwise it will run every tick.

  • Does that work for multiple instances?

    Find Path to Object.X, Object.Y doesn't work if that object has multiple instances. Does 'pick nearest' work for instances?

    If so, then perhaps this is simpler than I thought!

    In case of event "Player: Pick nearest Enemy"

    pick nearest picks the instance of the Enemy object, that is closest to the picked player object. So yes, it would work in your case to pick the nearest enemy. :)

  • Is there a way to make pathfinding prioritize one or any instance of an object?

    For example, in my space game I have multiple enemies that will be in different locations. When I have an ally ship spawn, I want it to focus one or any of these enemies and start chasing it. I have it set to find a path to Enemy.X, Enemy.Y, but since there are multiple enemies in play, the pathfinding fails to work.

    Is there a way to have pathfinding pick one particular instance of an object to follow?

    You'll need to define a condition to pick with; do you pick the closest enemy, most dangerous enemy, random enemy or with what criteria you wish to pick the enemy with? I recommend you take a look at the 'picking' section at FAQ thread, as at the moment you are applying same actions to all AllyShips and targeting the 'first' enemy at the list of picked enemy objects.

  • Try setting the individual objects dt to 0 under the system actions.

    Then use that objects dt in your expression "object.dt"

    Thanks newt, I just read that piece in the manual as well! :)

    Here is the quote for anyone that might come looking for the info:

    "Objects have their own dt expression (e.g. Player.dt) which you must use instead of the system dt for all motion relating to that object."

  • Set gravity to -200 instead of 200? Haven't tested, seems to me it would work :)

  • I've got a problem where I want to have neat, sliding menu icons that appear when I pause the game. Problem is that pausing (setting time scale to 0) breaks their movement, which is done via lerp(object.x, targetX, dt). I've tried setting the object timescales seperately to 1 after pause event, but it still doesn't seem to work. I am guessing dt is taken from game timescale?

    What would be the simple way of going around this problem?

    I'm going 100% natural here, so no plugins allowed! :)

  • Problem 1) There really is no solid solution (in my opinion at least) for saving layout state at the moment. Developers are working on it and have said there is something coming sometime in the future. In the meantime, here are few helpful things that might help you to come up with solution of your own: SpriteBank plugin, saves states of sprites and allows you to load them later. You can also set objects global in object settings, so they persist through layouts.

    Seems to me like you need to save your generated solar system and put it into desired state every time you move in to solar system layout.

    Problem 2) Global switch would probably work here, so stick man persists through layouts. You need to hide him in non-desired layouts though, like solar system layout.

    Hope these help :)

  • This might work for you: Lazor beams example

    Cleaned things up a bit, you don't need 'run every dt' conditions for anything really. Things run every tick by default unless you define otherwise :)