N
neXasDev
Guest
GML:
if state == 0 && instance_exists(ob_electron) { // Only if the wire is active and the the electron is present will this code run.
var e = instance_nearest(wire_start_x, wire_start_y, ob_electron); // Assign the nearest instance a temporary variable.
if point_in_circle(e.x, e.y, wire_start_x, wire_start_y, 4) { // If the electron comes within a radius of 4 pixels of the wire's first vertex this code will run.
electron_count[0] += 1; // Electron will store itself inside the wire's first vertex's electron count (electron_count[0]).
with(e) { // Electron object will destroy itself.
instance_destroy();
}
// This if statement keeps returning an error. It doesn't recognize e. I have tried using e as a normal variable as well. Same problem.
}
}