Palourde's Forum Posts

  • It seems that the condition "Object1 => On collision with Object2" is not triggered every time when the two objects have the Physics behavior. This is especialy true when the objects are colliding on a "flat" surface from their respective hitboxes.

    The collision is clearly visible on screen and everything looks ok with the physics, but "On collision" is not triggerded.

    After a few tests, it appears that the contact points (with expression "Physics.ContactCount") are allways correct, but "On collision" is sometime not triggerded even if ContactCount > 1.

    In my tests, no other conditions than "On collision" where involved and there is only two Physics Object (two different Sprites, not the same instace).

    Am I missing something when I check the collision between Physics Objects ?

  • Nice ! Thank you !

  • Hello,

    I want to get the overall speed of a Physic Object in order to apply a damage value based on the collision strenght between 2 Physic Objects. The only available expressions are Velocity.X and Velocity.Y.

    I first try to use something like (abs(Object.Velocity.X)+abs(Object.Velocity.Y))/2. I thought that if a perfect horizontal movement with velocityX = 100 and velocityY = 0 would leed to VelX = 50 and VelY = 50 for a perfect diagonal move at 330°.

    Instead, the values are more like VelX=70 and VelY=70.

    I wonder what how to retrieve the real overall speed value in any direction ?

  • I achieved to get the ratio between the rotation speed and the impulse strength with unlerp(0 ,90, anglediff(angle(B.x, B.Y, A.X, A.Y))) . This gives me the multiplyer to apply to the rotation speed. Then, "1-unlerp(...)" give me the multiplyer for the impulse speed.

    As said by dop2000, its not 100% accurate, but its hard to notice the difference between ths and a "real" physical hit.

  • Thank you guys, its working perfectly !

    I however had to add a couple of conditions to test if the bullet hits either the "front" or the "rear" of B (which looks more or less like a ship). Otherwise, the rotation direction was only correct when I hit the rear. The rotation is now applying correctly everywhere on the object.

    I ill now try to find the good ratio between the impulse strenght and the rotation speed depending on the angle of the bullet, but this should be easier.

    Thank you for your help !

  • Thank you very much for these annwsers !

    R0J0hound, your method looks amazing but my math level seems way too low and my brain melted somewhere in the process :(

    I'm trying to use a combination between El Constructor's and dop2000's methods. The "realisticness" of the result is not that mandatory for the gameplay, so this should do the job.

    First of all, Im trying to apply dop2000's method in order to retrieve the rotation direction. But I dont understand this point : "Let's say this difference is 20 degrees, so you apply an angular velocity in the opposite direction, -40 for example. "

    I use anglediff(angle(B.x, B.y, A.x, A.y), B.Angle), this will always gives me a result between 0 and 360. But angular velocity is either a positive or negative value(for clockwise or anticlockwise). Im probably a little stupid here, but I dont understand how a can apply an angluar velocity in the opposite direction of a number thats always positive (0 -> 360).

  • Hello,

    I want to apply an impulse to "sprite A" when "sprite B" collides with it. Object A has the behavior "Physics" but not object B.

    Here, "Sprite A" is the hitbox of an enemy and "sprite B" is a bullet fired by the player.

    An obvious solution would be to apply the physics bevavior to the two sprites, but this is unfotunatly not an option in my current project for other reasons. Only the enemy hitbox can have physics properties (in order to interact with other enemy hitboxes).

    When I want to apply an impulse with the "Physics" events, the impulse can only be applied at an image point. I dont find how to apply it at a custom point on a sprite (the impact point with the bullet).

    And last but not least, the hitbox is not a simple circle, the shape is more like a square. The impact point is also important because it will determine precisely how the "sprite B" will react to the impulse (angle, rotation, etc.).

    Basicaly, I want to simulate an impact between two "Physics" objects at a specific point, but ony the object which is hit can have the physics bevavior.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you soooo much ! its working perfectly !

  • I want the two sprites to appear at the same place on the screen, even if the two layers have different scale values.

  • Hello,

    I want to retrieve the position of a sprite the same way as the following expression for the Mouse objet : MouseX.("Layer A") and MouseY("Layer A").

    But this expression does not work for sprites.

    In my project, I have object A on Layer A and object B on Layer B. These 2 objects needs to apear always at the same position, but I want to change de scale of Layer A (and objet A). I want object B (on Layer B) to stay at the same position than object A on the screen.

    When I use somthing like < Every tick => set "ObjectB" position to "ObjectA" position > the coordonates of the two object will effectively remains the same even if ObjectA moves, but when I change the scale of a Layer, the two objects will be shown at different positions on the screen (even if their X and Y values are the same).

    I understand the reason of this problem, but I dont know how solve it.

    Any idea ?

  • After several tests, it seems that the shortcut ctrl+H only works when i launche a preview in a new tab. When the preview is launched in a new browser window, the shortcut ctrl+H seems to have no effect on the preview window, but this is independant from your script : if i disable the script, this shortcut remains inactive on the preview window. This is probably inherant to this particular shortcut.

    Shortcuts like ctrl+D or ctrl+S will still remains active on the preview window (or preview tab, i tested both), even if i put "KeyD" instead of "KeyH" in the script in your test project.

  • Thank you !

    Unfortunately this trick is not working, but maybe i am doing it wrong. I used "add script", then copy/paste your script in it, and i put it at the very top of the event sheet. I also tried to put it in an action, under an "On start of Layout" condition.

  • Hello,

    I want to use shortcuts like ctrl+d ant some stuff in my current project. Unfortunately, this triggers some browser shortcuts. Firefox and Chrome do not profide any options to disable or customize their shortcuts.

    Do someone have an answer to this ussue ?

  • Thank you, I will try to understand how it works. This could be a great alternative to NW.js.

  • Thank you for the advice !

    My goal is to create a portable device that will launch the game on startup and without any internet connexion.

    I dont know how the PWA works for now, do you think that its possible to preload the app once in order to use it in the browser offline ?