Is Solid behavior API not supported in scripting?

0 favourites
  • 4 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • I can't find a way to set a Sprite's Solid behavior state (enabled on/off) from scripts.

    I had to create a helper function in an Event Sheet to set the Solid behavior state and call the function from the scripts whenever necessary, but this is not ideal since I'm doing everything else from scripts.

    Is this not currently supported or am I missing something? I can't find Solid under "Scripting Reference / Behavior Interfaces" nor did I find any methods for doing this on IObjectClass, IInstance, and ISpriteInstance.

  • Hi ramtinsoltani, there is no interface for that yet, if it's not in the documentation then I'm afraid there's no support for it yet.

    However, this doesn't actually limit you. Similar to your mentioned workaround, you can still make your own event sheet features interface for scripting.

    1. Create a family named Solid.
    2. Add all your objects with a Solid behavior to the new Family named Solid.
    3. If there are event conflicts, due to the Solid behavior already existing in an object, you can just use a dummy object to replace them temporarily while you move your object's Solid behavior to the Solid family.
    4. Create a function for each action, condition and expression of the Solid behavior.
    5. Or, you can edit the project file's JSON to replace the object's individual solid behavior to its family.
    6. Make sure each function has a UID number parameter.
    7. Make function parameters based on the arguments of an action, condition or expression.

    Here is how it would look like:

    All objects belonging to the Solid family will be able to utilize the created functions.

    	const object1 = runtime.objects.Solid1.getFirstPickedInstance();
    	const object2 = runtime.objects.Solid2.getFirstPickedInstance();
    	const object3 = runtime.objects.Solid3.getFirstPickedInstance();
    	const object4 = runtime.objects.Solid4.getFirstPickedInstance();
    
    	runtime.callFunction("Set solid enabled", object1.uid, true);
    	runtime.callFunction("Set solid enabled", object2.uid, false);
    	runtime.callFunction("Set solid enabled", object3.uid, true);
    	runtime.callFunction("Set solid enabled", object4.uid, false);
    
    	runtime.callFunction("Set solid tags", object2.uid, "super-solid");
    	runtime.callFunction("Set solid tags", object4.uid, "weak-solid");
    

    You can do this for all event sheet actions, conditions and expressions. For all plugins and behaviors, even for the system.

    I hope that helps.

  • Thank you for the detailed workaround. I appreciate the time you took to post your answer.

    And that's almost exactly what I did (except for the tags which I'm not using at all)! I'm changing the solid state using a family of objects + UID and state parameters of that function.

    Do you know what is the procedure for requesting a feature?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Do you know what is the procedure for requesting a feature?

    Hi ramtinsoltani, yeah it is in Announcing a new Construct 3 suggestions platform (21H2).

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