Having problems with graphical hiccup

Get help using Construct 2

Post » Wed Feb 13, 2013 4:17 am

Capx : https://www.dropbox.com/s/lgqw6b0895ewzq4/sheepherder.78.capx

Moments after the start of the capx you can see the problem, the sheep reaches the dog and instead of stopping or moving away from the dog (The latter more preferable than the former... but either would help!) the sheep sits there and proves Schrodingers' cat was an amateur.

The sheep immediately trys to exist in both the state of toward the dog and away from the dog at the same time. I can't seem to get the sheep to pick one state or the other.

I'm trying to get the sheep when "afraid" to move away from the herd object. Ergo, the Hdesire and the fear equation: (100-(distance(dog.x,dog.y,sheep.x,sheep.y))) Which SHOULD increase the "fear" the closer the dog and sheep get to one another until Hdesire (the desire to herd up) is much smaller than the desire to run from the dog.
With Hdesire at 10, when the dog closes to within 90 px of the sheep, it should switch to "fear" and stop "herd".

Instead it sits and spins, even when well within the 90 px range.

1. How do I fix that, force it into only one state, not both?

Also: Adding a while in any of the three sheep functions crashes the game. All you get is a blank grey screen, or if it works, as soon as the event is triggered it locks up.

2. I can't seem to get C2 to compare to global variables. If I try to declare fear to be an equation (100-(distance(dog.x,dog.y,sheep.x,sheep.y))) it won't store the value and defaults back to 0. If I set an On Start of Layout fear = (100-(distance(dog.x,dog.y,sheep.x,sheep.y))), it will not bring fear up as an option when I want to compare to variables as a system action.
B
3
Posts: 6
Reputation: 312

Post » Wed Feb 13, 2013 6:07 am

@FadeDown

When your sheep breaks the threshold of being scared of the dog and backs away, the very next step away from the dog puts it back under the threshold, thus it turns around again.

You could either make those check every x seconds (which gives the sheep time to move away before checking again) or you could implement a cooldown timer for the sheep with an instance variable so that it keeps going it's last direction for a bit before checking again.

I added a every 0.5 second condition to both of your last two checks and it smoothed it out a bit.

You've still got a bit more logic to do, but that's the direction I'd head, IMHO.theubie2013-02-13 06:07:22
B
26
S
8
G
3
Posts: 210
Reputation: 5,973


Return to How do I....?

Who is online

Users browsing this forum: tarek2, Yahoo [Bot] and 19 guests