Using PVs from one object in another

For questions about using Classic.

Post » Thu Jul 09, 2009 8:19 am

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.
B
1
G
3
Posts: 3
Reputation: 831

Post » Thu Jul 09, 2009 8:33 am

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.
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Thu Jul 09, 2009 9:11 am

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.
B
1
G
3
Posts: 3
Reputation: 831

Post » Thu Jul 09, 2009 9:29 am

You should go through the ghost shooter tutorial, and deadeye's platform school :).
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Thu Jul 09, 2009 4:20 pm

[quote="Rich":34d7t7x7]You should go through the ghost shooter tutorial, and deadeye's platform school :).[/quote:34d7t7x7]

There should be a pop-up when people register that tells them to do just that.
B
6
S
2
G
3
Posts: 520
Reputation: 2,690

Post » Thu Jul 09, 2009 5:38 pm

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.
B
1
G
3
Posts: 3
Reputation: 831


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests