|
Post by baroquelesnar on Feb 22, 2016 15:47:28 GMT
so, i have 5 rigidbodies and i want that every time the first one of those touches the others it adds a point in my valueprint, how to do it?
|
|
|
Post by Power Supersport on Feb 22, 2016 16:01:44 GMT
You're glad that you ask a pretty simple and fast question... What you do is: Make an EOC (Event on contact) and connect all 4 rigidbodies to it, being set to MONITOR... Connect the fifth one (the target one) and set it as MONITOR (REFERENCE)... Check the mark: "Ignore collisions that don't involve the reference objects... Add a script and paste this down below... Add a ValuePrint... IMPORTANT! Connect the script FIRST to the EOC and SECOND to the valuePrint... And you're ready to go!
int point; int time;
void Main() {
if (IN_0 > 0) { time += 1; if (time == 1) { point += 1; } } else time = 0;
OUT_22 = point; }
|
|
|
Post by baroquelesnar on Feb 23, 2016 0:45:21 GMT
thanks Power, you'tha man i hate to be annoying but is there a way to restart the value to 0 on input too? thanks again you're the best
|
|
|
Post by Power Supersport on Feb 23, 2016 8:34:05 GMT
Even way easier than this...
Just connect an EventOnInput to the existing script...
Abd paste this one... This is the edited script...
int point; int time;
void Main() {
if (IN_0 > 0) { time += 1; if (time == 1) { point += 1; } } else time = 0;
if (IN_44 > 0) { point = 0; }
OUT_22 = point; }
|
|
|
Post by commended on Apr 7, 2016 8:40:29 GMT
You're glad that you ask a pretty simple and fast question... What you do is: Make an EOC (Event on contact) and connect all 4 rigidbodies to it, being set to MONITOR... Connect the fifth one (the target one) and set it as MONITOR (REFERENCE)... Check the mark: "Ignore collisions that don't involve the reference objects... Add a script and paste this down below... Add a ValuePrint... IMPORTANT! Connect the script FIRST to the EOC and SECOND to the valuePrint... And you're ready to go!
int point; int time;
void Main() {
if (IN_0 > 0) { time += 1; if (time == 1) { point += 1; } } else time = 0;
OUT_22 = point; }
I found an easier way to achieve this without scripting. 1) Add a counter and set initial value to whatever you want your value to be at the beginning, then set increment to -/+ whatever you want the value to add or subtract. Wrapping/clamping range can be ignore and set 'cross-project file' panel to read at startup and write on exit. 2) Add a Value Print and link it to the counter then set its relationship to "counter is value to print" before adding an event on contact to the project, link the event on contact to the counter and set relation to start on contact. 3)Finally link to the two (or more) rigibodys to the event on contact and set them to monitor.
|
|