0
$\begingroup$

i having a bit of trouble understanding how the signals to a message sensor works, it seems like when it gets turned on it does not stay on for very long.

I'm trying to make simple system to display the winners on the screen, out of four players the last one that's standing will get there text written in the center, in a few second before the game will reset.

Here i have 2 sensors connected, they work if they happen at the same time but not if they are delayed a second from each other.

Here i have 2 sensors connected, they work if they happen at the same time but not if they are delayed a second from each other.

I feel like I'm misunderstanding how the timings work of the sensor.

Thanks you very much for taking you the time to help me :)

$\endgroup$
0
$\begingroup$

Messages

You need to consider the duration and timing of messages.

A message is send between two frames.

Timing:

  1. the first frame it will be send
  2. the following frame it will be received

The duration of a message is .... exactly one frame. A message sensor will receive this message never again (it can receive another message of the same format).

A message is more an event rather than a status.

Your logic: p1de AND p2de expect that a message p1de and a message p2de are received at the same frame.

It does not mean that any of the messages were received in the past.

Solution

The winner is a status. At any moment there is exactly one winner. This status can change.

There are two basic options to do that:

  • Change on event: The event carries enough information to decide the new winner.
  • Notification: The object gets notified the winner (might have) changed. The object checks the situation and determines the current winner.

With the first option you need to deal with the situation you might get events that conflict with each other (e.g. you get a message telling the first player wins as well as a message the second player wins). The message recipient has to resolve the conflict.

The second option needs deep knowledge how to determine the winner.

Hint:

Do not combine messages with AND.

It expect both messages to be received at the same time.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.