[behavior] rex_LJpotential (attracting or rejecting objects)

Post your completed addons to share with the community

Post » Tue Sep 02, 2014 7:10 am

@justiffun

The foumla of this behavior is
(A/(r^n)) - (B/(r^m))
For example, n=1 , m=2
A/r - B/(r*r)
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

Post » Tue Sep 02, 2014 1:57 pm

@rexrainbow

I'm not very good at math, so i was trying to figure out how changing those values affect how the objects move.

for example:
It appears that increasing "A" makes the objects attract stronger to one another
what does "n" and "m" do?
B
82
S
39
G
14
Posts: 980
Reputation: 16,208

Post » Wed Sep 03, 2014 1:10 am

@justiffun
The bigger n, the attracting will get smaller at the same distance.
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

Post » Fri Sep 26, 2014 8:20 am

@rexrainbow
Useful stuff as usual. Right now I'm trying to figure out one thing:

- There are two types of units: enemy units and player's units
- Enemy units are attracted to the players units and the other way around (this part is working)
- But at the same time player's units should reject other player units and the same for enemy - I can't figure out how to do it

If I change "B" from 0 to some higher value, they start to reject opponent's units. Right now I'm using Source/Target Tags for differentiation. I think the problem is that the units of the same type do not consider other units of the same type as source, and that's why rejection doesn't work. I'm gonna try to use groups for differentiation.
B
45
S
11
G
4
Posts: 515
Reputation: 7,389

Post » Fri Sep 26, 2014 8:40 am

@xoros

Yes, tag system in this behavior has limitation. That's way I add instance group supporting (calculation manually) for advance. Moreover, user could rest A,B,n,m before calculation.
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

Post » Fri Sep 26, 2014 10:00 am

I tried to set Attraction Parameters on runtime - but there's no possibility to set a number: "SetLJpotential LJ parameter" - only a pulldown menu with parameter
B
45
S
11
G
4
Posts: 515
Reputation: 7,389

Post » Fri Sep 26, 2014 10:08 am

@xoros

Thanks for finding this bug. I had updated this behavior to fix it, please download it again.
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

Post » Fri Sep 26, 2014 10:38 am

Cool :)
B
45
S
11
G
4
Posts: 515
Reputation: 7,389

Post » Fri Sep 26, 2014 11:12 am

@rexrainbow
Hmm, still can't figure out how to reject the same unit type and attract to the opposite units. Basically it's like magnets: blues reject blues but attract reds, and reds reject reds but attract blues.

What I'm doing right now:

- unit on created > add to the "reject&type" group, add to the "attract&type" group
- for each unit > clean force; pick "reject&type" group; set LJ potential B to 10; Attracted by source Units; set angle to force
> pick "attract&type" group; set LJ potential A to 10; Attracted by source Units; set angle to force

Please, halp
B
45
S
11
G
4
Posts: 515
Reputation: 7,389

Post » Fri Sep 26, 2014 11:26 am

@xoros

I am not sure, will you provide a sample capx? It is also an interesting demo I guess.
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 0 guests