Add attribute not working properly?

For questions about using Classic.

Post » Sun Apr 03, 2011 7:50 pm

I've been having trouble with the "add attribute" action lately, so to find the cause I used it in an extremely simple event and it just... isn't doing it right. I dunno what else to say. The event just says:

Item PV Equal to 2: Add attribute "Solid"

Nothing more than that. For some reason, sometimes it WILL make it solid... after waiting about ten seconds or so. :P I tried debug mode and the PV is working fine, so it isn't that, and there's no other event in the entire game that might add or remove attributes to Item. For testing purposes, I added another PV called "Solid" that gets set to 1 after the add attribute action, and even that works like it should. Even so, there's a huge delay in making it solid or it doesn't happen at all.

Is this a bug?
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Sun Apr 03, 2011 8:20 pm

If you don't need it to colide with anything before it is set to solid you could do this


Set it the solid in the layout editor
Start of layout set it's collision mode to none
When PV=2 set the collision mode to per pixel/box etc


Not sure about how you are doing it at the moment, have not tried to do anything with adding atributes.

also have a look at if this would work

Set the atribute to solid in the layout editor
Start of layout change the atribute
PV=2 set the atribute to solid

Just incase there was some issue with assigning atributes at run time. Who knows, right.

Now Newt will reply underneath this and have all the information and the perfect solution for you!
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Post » Sun Apr 03, 2011 8:47 pm

Its true, I'm on here way too much.
Anyway Steven's suggestion is usually what I would do instead of trying to add the attribute.
The way its acting tho does suggest that perhaps your comparing an integer to a float.
IE 2 does not equal 2.1, or 1.9.
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

Post » Sun Apr 03, 2011 10:01 pm

The float thing occurred to me, but like I mentioned in the original post, for testing purposes I changed it to:
Item PV Equal to 2:
- Add attribute "Solid"
- Set pv "Solid" to 1
And "Solid" is indeed set to 1 when it's supposed to, which wouldn't happen if the comparison wasn't working.

Anyway, your suggestion... well, I don't think it can work for what I'm doing. I wanted to keep the description vague, but oh well, here goes. :P

The item is a hammer that Mario can use in my game. While carrying it around, it's part of his sprite rather than an actual object, but when you get hit by an enemy and shrink to small Mario, it creates a hammer object and drops it to the ground. Small Mario isn't strong enough to use the hammer, so when Mario's health is 1 (meaning he's small), the hammer should be solid. When his health is 2 (Super Mario, and thus strong enough to pick the hammer up again), it shouldn't be solid so he can overlap it and pick it up. I can't use any start of layout things because the hammer is created during run-time, so the only other thing I can think of is adding and removing the solid attribute.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Sun Apr 03, 2011 10:11 pm

You could always loose the attribute, and just use a state machine with object is overlapping at offset.
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

Post » Sun Apr 03, 2011 11:11 pm

"State machine"? Never heard that one before. :?
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Mon Apr 04, 2011 2:15 am

You've already used them.
Item PV Equal to 2: Add attribute "Solid" is a state machine.
So if hp > 1 ... hammer time
hp < 2 ... cant touch this
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

Post » Mon Apr 04, 2011 4:10 am

Ohh alright. I had no idea that's what it was called.

[quote="newt":3ptn4vjj]So if hp > 1 ... hammer time
hp < 2 ... cant touch this[/quote:3ptn4vjj]

Ahah, you're too late! I already made that joke in the comments of my project. :D
B
20
S
9
G
6
Posts: 607
Reputation: 6,112


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests