(Suggestion) other expression

0 favourites
  • 11 posts
From the Asset Store
Add this awesome sound effects to make your visual novel come to life!
  • I was wondering if you guys can add an other expression

    this would return the other instance of an event if there is one

    it would cut down code a ton and would be just plain simpler to use

    for example in a collision event you could make a damage function do

    accelerate towards angle (self.X, self.Y, other.X, other.Y)

    this way you only need to use one parameter for the knockback strength instead

    having to include 2 other parameters for the angle

    and keep in mind this would just be something I would do with it

    it could be a major short cut for everybody

    and would be extremely useful

  • I'm not sure exactly what the "other" expression would refer to. In your description it seems to be defined as "a magic expression that does what I want". What exactly would it refer to? There are a great many "other instances" it could potentially refer to, how should the engine pick which one you mean? Also in your example "Self" and "Other" are used as object type names, which are not object instances.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I was wondering if you guys can add an other expression

    this would return the other instance of an event if there is one

    it would cut down code a ton and would be just plain simpler to use

    for example in a collision event you could make a damage function do

    accelerate towards angle (self.X, self.Y, other.X, other.Y)

    this way you only need to use one parameter for the knockback strength instead

    having to include 2 other parameters for the angle

    and keep in mind this would just be something I would do with it

    it could be a major short cut for everybody

    and would be extremely useful

    Solution is to make a family, which include all *other* objects, pick nearest *other* and do the angle()

  • I'm not sure exactly what the "other" expression would refer to. In your description it seems to be defined as "a magic expression that does what I want". What exactly would it refer to? There are a great many "other instances" it could potentially refer to, how should the engine pick which one you mean? Also in your example "Self" and "Other" are used as object type names, which are not object instances.

    sorry it would return the other instance of a condition not a event

    like for say if placed inside a (is overlapping event) or a (on collision of another object) condition it would return the object it would return the object chosen in that event

    however if it was placed in a event like (is between angles)

    it would normal return (null ,nil, -1)

    however if it was placed in a (is between angles) in a (is overlapping event) or a (on collision of another object) condition it would return the object it would return the object chosen in the collision event

    basicly it would return the other instance in a condition if there was one

    else would return a null value or -1

  • If I understand what you mean, what you ask is already there:

    This will pick all instances that meet both the first AND second condition.

    This will pick all instances that meet either the first OR the second condition.

    Right click and select "Make Or block"

  • immortalx

    I want to get the direction of the collision of the other object

    which in your case is blue

    not myself

    and I can't perform any arithmetic functions on it because I can't return the other object inside the condition statement

    this is going to be inside a function called when the two sprites collide

  • Shadowblitz16

    I feel terribly sorry for not understanding what you mean (English is not my native language).

    Can you post a capx just to make sure we both talk about the same thing?

  • What if there are 5 other conditions in the event which all refer to different object types? What if there are hundreds of "other" instances to choose from? How do you know which will be referred to by "other"? This seems far too ambiguous to be useful at all.

  • What's wrong with using families ?

  • Ashley it could be done in the order of conditions.

    for example other(0) - other(4) for 5 conditions that refer to the other object

    Edited spongehammer this is why

    I want to do something like

    function knockbackEntity(strength)

    set acceleration

    (functionParam(0))

    (other(0).X,other(0).Y,self.X,self.Y)

    I don't see how to do this with familys that allows it to be this customizable

  • I understand what you mean. And the collision example is a good one to demonstrate it.

    When a collision occurs, there are 2 objects involved in that situation. For ex. a player and an enemy. If we focus our events on the player and create the "Player on collision with enemy" then we could reference the other object with this expression (in this example, the enemy). Yes, it can be done with families, but not in the free edition. Also, you don't have to create families for different groups of objects if you can use the "other" expression. It may help developers who think differently to those who use families efficiently. Also, the collision is just one example, I'm sure it would be useful in differens situations as well.

    What if there are 5 other conditions in the event which all refer to different object types? What if there are hundreds of "other" instances to choose from? How do you know which will be referred to by "other"? This seems far too ambiguous to be useful at all.

    These are indeed problems with this idea. Maybe it should be a Sprite only expression. I don't think it would be a problem if there are hundreds of instances. Staying with the example: the collision event would run for every collision, so picking the other instance there can work.

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