R0J0hound's Recent Forum Activity

  • Prominent

    The contact depth should be the distance from the edge, but I'll look into it. The point query condition will give a negative queryDist when the point is inside a shape.

    mattb

    That appears to be how the chipmunk library works. Those contacts flicker on and off when you look at it continually. I'll probably investigate further.

    I'll try to get those bugs fixed tomorrow. I'm also going to do some internal tweaks to better address future issues and hopefully prevent them.

    Documentation tidbit:

    The collision layers property is a list of 32 layers and whether an object is in one or not. I opted for 8 hexadecimal digits instead of 32 binary to shorten it.

    The default value: ffffffff means the object is in all the layers. Whereas 00000001 means the object is in that one layer.

    If you don't need all 32 layers and don't want to deal with hexadecimal numbers you can use 1 or 0 and have 8 layers.

    The objects can collide if any two digits are both 1. For example:

    Obj1 00000001

    Obj2 11111111

    They can collide.

    Obj1 00000001

    Obj2 11111110

    They won't collide.

    Obj1 11110000

    Obj2 00001111

    Obj3 11111111

    Obj1 won't collide with obj2 but both can collide with obj3

    Another way you can think of it is as a set of rules of what is allowed to collide with what.

    Player collides with wall, enemy and enemy bullets but not player bullets

    Wall collides with everything

    Player bullet collides with enemy and walls

    Enemy bullet collides with player and wall

    Enemy collides with wall, enemy and player bullet.

    Then you assign a layer to each

    Wall, player, enemy, player bullet, enemy bullet

    And with the rules set the layers accordingly:

    Wall 11111

    Player 11101

    Enemy 11110

    Player bullet 10110

    Enemy bullet 11001

    Another idea would be to have a seperate background layer with something moving and you don't want the player colliding with it. So for that the player's collision layer could something like 0001 and the background 0010.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Prominent thanks for the report. I'll be looking into it.

    spongehammer

    You can already get the impulse applied to a joint so yes you can make something like that.

    kmsravindra

    #1 Physics libraries are only a approximation, so energy isn't always conserved. You can increase the "global settings"->iterations to make it more accurate. You can also make the fixed timestep smaller to make collisions more accurate as well.

    #2 Toggling immovable isn't the best way to drag objects around. The switch discards any contact points and isn't very physically correct. A better way is to attach a joint to an object that is moved directly. See bottom of post.

    #3 If it causes a js error then it's a bug. I'll look into it.

    spongehammer

    It's correct, elasticity in physics is how a collision reacts, not how rubbery it is. An elasticity of 1 should mean that no energy is lost in a collision, which is pretty much how ball bearings act when they collide.

    Attached is a physics way to drag objects around. When you click on an object you create a joint to a no collision, immovable sprite that is moved around by the mouse. Then when the mouse is released the joint is removed.

    Also the joints in the capx are set to break if you're too rough.

  • Best I can tell it has to do with the "extend-box" property in the effect's xml file. When it's 0 the texture space (0.0 to 1.0) is from the left of the sprite to the right. But when it's non zero 0.0 is the left of the screen and 1.0 is the right. Also the following effects will inherit the same texture space.

    Here are all the variables that C2 sets for effects to use:

    pixelWidth
    pixelHeight
    vec2 destStart
    vec2 destEnd
    layerScale
    layerAngle
    vec2 viewOrigin
    vec2 scrollPos[/code:1mk58yqb]
    
    I think destStart and destEnd are the topleft and bottomright texture coordinates or something like that. Could be of use.
  • Cool effects!

  • You can use the physics behavior or this behavior with ball sprites that have their elasticity set to 1. Also you'll need to set the gravity to zero.

    You could also use this for a more perfect collision response. If it's an issue that is.

  • R0J0hound, I replaced the sprite 2, which overlaps a tile, with a bullet. While bullet is colliding with a tile, the effect of overlapping does not appear. What was wrong?

    It looks fine here. Slow the bullet if you want to see it longer.

  • "this" is undefined in your code. Setting "self" to "this" doesn't change that in this case.

    Read the "Function context" for the reason why:

    https://developer.mozilla.org/en-US/doc ... ators/this

    "close" is clicked and the then it calls onUIDialogClose() which in turn try's to call this.runtime.trigger().

    But this is undefined since onUIDialogClose isn't called from an object.

    Use the mouse plugin as an example. It sets up the callbacks from the onCreate function. That way the callback can know what self is.

    instanceProto.onCreate = function()
    {
    	var self = this;
    	jQuery(document).mousemove(
    		function(info) {
    			self.onMouseMove(info);
    		}
    	);
    }
    
    instanceProto.onMouseMove(info)
    {
    	this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnAnyClick, this);
    }[/code:3inczl09]
  • Update 2.0:

    Download in first post.

    * Fixed: Joint tags were not working.

    * Added: "for each collision pair" condition. "on post collide" only triggers when an object first hits. This will loop through all the current contact pairs.

    Document tidbit:

    Joint tags can be any string when adding joints. When using it in joint expressions you can also use a number index.

    So do this to get the type of the first joint

    Sprite.Chipmunk.jointType(0)

    Or the second:

    Sprite.Chipmunk.jointType(1)

    Also you can give more than one joint the same tag name. Using it in a expression will give the last joint with that tag. This allows you to modify the joint that was just added.

    So if you added two pin joints, both with a tag of "". Then the following expression will get the impulse applied to the second joint.

    Sprite.Chipmunk.jointImpulse("")

    Also attached is an example using the new "for each collision pair" condition.

  • "on post collide" is only triggered when two objects first collide (useful for sound). I need to add another condition to loop over all the collision pairs so you can check at any time.

  • Prominent

    Here's a proof of concept in events to see how it would handle. The result is decent, but it becomes much more complex if we wanted to use tile collision polygons. It would also take a while to implement this in a good js way. So long term I may implement something into the behavior but not at the moment.

  • Update 1.9:

    Download in first post.

    * Fixed: If a shape or joint was destroyed more than once it would crash.

    * Fixed: Expressions would sometimes return undefined if there wasn't any value. Now 0 is returned.

    * Added: "set joint properties" action to change joint specific properties after the joint is added. Things like spring stiffness, pin distance, etc ... see note[1]

    * Added: A bunch of expressions to get those joint specific properties: see note[1]

    joint_PinDist(tag)

    joint_SlideMin(tag)

    joint_SlideMax(tag)

    joint_SpringRest(tag)

    joint_SpringStiff(tag)

    joint_SpringDamp(tag)

    joint_RotaryLimitMin(tag)

    joint_RotaryLimitMax(tag)

    joint_RatchetAngle(tag)

    joint_RatchetPhase(tag)

    joint_RatchetRatchet(tag)

    joint_GearPhase(tag)

    joint_GearRatio(tag)

    joint_MotorRate(tag)

    * Added: An expression to get the joint's type as text: jointType(tag)

    * Added: Expressions to get the points that a joint connects to the objects. Either the current object or the other one:

    jointAnchorX(tag)

    jointAnchorY(tag)

    jointOtherAnchorX(tag)

    jointOtherAnchorY(tag)

    Note [1]:

    If the action or expression used doesn't match the joint type then the action will do nothing and the expressions will return 0.

    Prominent

    Line segments might help with that but I currently have no plans to implement it.

    You could bevel the player's collision polygon a bit.

    -cheers

    Edit:

    Last minute fix. Re-download version 1.9.

    * Fixed: "Enable/Disable" and "Set immovable" actions would crash trying to remove a shape more than once.

  • Is the trigger function throwing the error? What does alert(this.runtime.trigger) give you?

    Edit: you can call the function but since the calling function isn't part of the instance object, "this" isn't an instance so it doesn't have this.runtime.

    If your object only ever has one instance you could add a global var that you set in your onCreate function to be "this", then you can use the var instead in your function.