Using PVs from one object in another

This forum is currently in read-only mode.
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Greetings, all.

    I am, as you can guess, new here. I have used a few other authoring programs, and just recently stumbled across Construct. So far, I am very fond of it. The logic is rather different than I am used too, but the ease of use and performance is wonderful.

    Anyway, to my newbie'ish questions:

    Basically, I am having a difficult time using the Private Variables from one object in a calculation run by another object.

    To give you an idea of what I mean:

    I have a bullet object. This bullet object has a PV 'Damage'. This is the variable that records exactly how much damage this particular type of bullet does.

    I, then, have an enemy object. This enemy object has a PV 'Health'. This, of course, determines how much "Damage" it can take before it is destroyed. All very standard, basic stuff.

    What I am attempting to do is have a a collision event between enemy and bullet, where PV 'Health' is subtracted by the bullet's PV 'Damage'. I am sure there is an easy, intuitive way to do this, but I have not found it, yet.

    I thought it would be easiest to use the "Subtract from private variable" action from the Enemy object, and put in Bullet.Damage as the amount subtracted. Of course, I get the error "The following variable: 'Bullet.Damage' of 'Enemy' is undefined. Would you like to define it?". I understand why. It is defined in the Bullet object... but not in the Enemy. The action is being run by the Enemy. The question is how do I get this to work?

    And, no, just putting the Bullet object's damage as a # in the action will not work. Well... it will... but not the way I am looking for. How do I get one object to be able to use the Private Variables of another object in its actions?

    Thank you, ahead of time, to all who take the time to answer. Greatly appreciated.

  • The only reason you would get this: "The following variable: 'Bullet.Damage' of 'Enemy' is undefined. Would you like to define it?" is if the variable does not exist. Generally that only happens when something is misspelled. That is if it was set up correctly.

    You might post a cap, its much easier to figure out that way.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Okay... figured it out. Turned out it was what I was suspecting it was, all along. Just a syntax error. I was using syntax from a different program, instead of the correct syntax for Construct.

    To illustrate what I mean, I was writing the variable as Bullet.Damage (as well as any other variation I could think of such as Bullet.'Damage', 'Bullet.Damage', etc), when what I needed to be writing was Bullet('Damage'). Always the simple things that get you.

    Thank you, Newt, for the quick reply. I appreciate it.

  • You should go through the ghost shooter tutorial, and deadeye's platform school .

  • You should go through the ghost shooter tutorial, and deadeye's platform school .

    There should be a pop-up when people register that tells them to do just that.

  • Actually, I have done them. That is how I figured I was making a syntax error. I remembered seeing the Ghost Shooter Tutorial using Global variables. I figured the syntax for the two had to be basically the same, so I went back and looked at how it was written there. That is when I noticed it used a location('name') type syntax instead of location.name type.

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