access elasticity

This forum is currently in read-only mode.
From the Asset Store
Web3 Integration
$2 USD
60% off
This is a simple login feature to access Metamask in construct 3. Requires a Chrome Browser and Metamask Extension.
  • Hi Folks,

    This is my first time using Construct - I like it very much!I have some questions, though, I'd very much appreciate a solution

    • Is it possible to access the physics elasticity in runtime? That is can I change a the elasticity value of a spawned object?
    • When I store the UID of an object in another objects private variable "parent", could I acess this stored object in a way like: (cube.Value('parent')).X ? I know that this does not work, but maybe there is a way to access the object in a similar way? The only solution I had is:

    pick object by comparison cube.Value('parent') is Equal to circle.UID

    This does work, yet only if you also know the kind of obect that the parent is. When you want to be more flexible, like spawn a bullet from different kind of enemies and store from which enemy (the parent), and access some variabel of the enemy, how would you achieve this in a more flexible way?

    Thanks for replies,

    Maenny

  • - When I store the UID of an object in another objects private variable "parent", could I acess this stored object in a way like: (cube.Value('parent')).X ? I know that this does not work, but maybe there is a way to access the object in a similar way? The only solution I had is:

    pick object by comparison cube.Value('parent') is Equal to circle.UID

    This does work, yet only if you also know the kind of obect that the parent is. When you want to be more flexible, like spawn a bullet from different kind of enemies and store from which enemy (the parent), and access some variabel of the enemy, how would you achieve this in a more flexible way?

    1. You could store a value in a "enemyType" variable, I guess.

    2. You could check out things like Containers (which links together one instance of several objects into a group) or the Pairer Object (which links together any number of instances of two objects into a group). For something like an enemy that shoots many bullets, the Pairer object is probably the way to go for what you want to do... whatever it is that you want to do . Of course I might be confused about what it is you want to do, perhaps you could be more specific? Posting a .cap always helps.

    Also... I'm going to go out on a limb here and say you came from an MMF background? Usually the only people who are concerned with object UID's are ones who are familiar with MMF. In Construct you really don't need to be except under rare curcumstances. 99% of the time you won't ever have to even think about an object's UID.

    If you ever want to perform a task and you're falling back on UID's, don't be afraid to post an example .cap and say "how would I do this in Construct?" Chances are there is an easier way that what you're attempting.

  • ok, here is what I do:

    I have about 8 different objects with a drag and drop behaviour. I want the player not to be able to drag one object over the other, so he can only place the objects in a free space. Furthermore, I don't want the collisions to be exact, but a collision mask in a circle with a given raduis around each object. I can't use a custom collisionmask, because each object has a physic-behaviour that needs the exact collisionmask. Also it would be quite complicated to have 8 collisionevents in each of the 8 objects. So what I did was to create an extra, invisible object in form of a circle which I attached to each of the 8 objects. Of course I could have done 8 collision objects which I put in a container with each of the 8 main objects - but I thought that quite complicated. So I created ONE collision-object for all 8 objects. In its events I programmed, that when it would overlap with one of his kind, it tells that the main object, which changes its filter colour to red and would go back to its initial position when the left mouse button is released. This means, I have to always make sure that the right collision object is exactly on the position of its parent. I solved this by creating the collisionproject at startup, giving him the UID of the parent and, in case of drag and drop, picking the object by comparing the stored parents UID with the UID of the selected object. This works well, but I wonder if there is an easier way.

    And no I did not come from MMF, but from gamemaker, where I solved many problems using IDs, that's true. And I have to admit, that I sometimes have difficulties to get used to the construct-style. For example in gamemaker one could use scripts, that you'd execute with passing arguments - for example an object ID. That was very useful, you could use the same piece of code for many different objects, you only had to pass the object ID to the script and it would execute all the code with exactly this object. I don't seem to find a similar possibility in contruct, but maybe I just have to change my way of thinking

    Thanks for the reply,

    Maenny

  • ok, here is what I do:

    I have about 8 different objects with a drag and drop behaviour. I want the player not to be able to drag one object over the other, so he can only place the objects in a free space. Furthermore, I don't want the collisions to be exact, but a collision mask in a circle with a given raduis around each object. I can't use a custom collisionmask, because each object has a physic-behaviour that needs the exact collisionmask.

    Okay then. I don't know if I fully understand, but I attempted to recreate what you described here:

    http://www.box.net/shared/6quet854gu

    It doesn't use physics or anything, but I commented the events so you could get a handle on how the picking works.

    Click and drag any red circle. If the cursor is overlapping another, unselected red circle then the one you have clicked will not update it's position.

    As for performing actions on individual instances, you simply need to define the instance in the condition of the event. You can get as specific as you like with multiple conditions. Just about anything can be used to compare instances to pick them for actions... overlap, variables, position, opacity, family, whatever. As long as you have the criteria for a specific instance defined in the condition, only those object instances that meet the criteria will have the actions performed on them. This is why UIDs are all but obsolete, because there are so many ways to select individual objects for manipulation. Of course you are still free to use UID's if you like, that's why they're there, it's just that a lot of folks coming from other game makers seem to have this habit left over. It's all good, I'm sure Game Maker would be different and confusing for me if I took a crack at it

    Passing arguments and re-using code could be done with the Function object, or with loops, depending on the situation. Of course, if you have a general "move around" action for all of your objects then they will all move around, unless you specifically leave some out during the picking process.

    For more information about how picking works, check out the wiki. There's some more in-depth stuff there: http://sourceforge.net/apps/mediawiki/c ... ct_picking

    Oh, and as for your setting the elasticity of an object at runtime, you might want to hit up the Feature Request forum for that. Physics is David's baby, you might be able to convince him to add that in there. I know his creed is to make things as good as they can be, I'm sure he'll look into it eventually if you ask nice and don't call him a lazy Australian

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • wow, thanks for the cap, although I seem to have difficulties in opening it (says: not enough memory), maybe I'll have to try with my PC at home (currently I have only my laptop with me - which works with other caps (much bigger caps) so far...).

    As for the problems with the users of other Gamemakers: I can understand the search for the UIDs (being myself one of them

    So as I understand, atm there is no way to access the elasticity of an object. I surely will post a feature request in the adequate manner.

    Thanks again for the fast reply,

    Maenny

  • Hmm, that's strange about the .cap not opening...

    I suppose I should also mention it was made in 0.99.72, just in case you were using an older version. Here's the 72 thread if you need it:

    And as for the whole UID thing, like I said feel free to use them. That's what they're there for . Usually when I have to select out a single instance from a group I assign a value to a PV and then use that PV to pick by, but you could totally use UID in the same manner if it's more comfortable.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)