rex_ljpotential
( A / (r^n) ) - ( B / (r^m) )
for attracting or rejecting objects.
This behavior would not change any property of instance. It only calculates steer force for reference.
This behavior would not change any property of instance. It only calculates steer force for reference.
Follows these steps to get steer force.
- Call "Action:Update" to update steer force.
- Check if the result of steer force is not 0 by "Condition:Has force".
- If there has steer force, get this force by "Expression:ForceAngle" and "Expression:ForceMagnitude" in polar axis, or (Expression:ForceDx, Expression:ForceDy ) in orthogonal axis. Use these info to control sprite like rotate the instance to this angle.
Source and target
Object could be classified into "Source" or "Target", which is set in properties table. They both have tag properties, "Source tag" and "Target tag". Target will be attracted with sources which have the same tag.
A object could be a source and a target immediately.
Object could be classified into "Source" or "Target", which is set in properties table. They both have tag properties, "Source tag" and "Target tag". Target will be attracted with sources which have the same tag.
A object could be a source and a target immediately.
Source
Attracting source. It provides steering force calculated by Lennard-Jones potential formula, parameter A, n, B, m could be set in properties table, or by "Action:Set parameter". r is the distance between source and target.
Attracting source. It provides steering force calculated by Lennard-Jones potential formula, parameter A, n, B, m could be set in properties table, or by "Action:Set parameter". r is the distance between source and target.
- A : magnitude of attracting
- n: declined of attracting
- B: magnitude of rejecting
- m: declined of rejectin
Only source objects which the distance is equal or less than "Sensitivity range" will affect targets. "Sensitivity range" could be set in properties table or by "Action:Set sensitivity range", 0 is infinity. i.e this source will always affect targets.
When a target has been attracting, "Condition:Begin attracting" will be triggered. Get the target by "Expression:TargetUID".
"Condition:End attracting" will be triggered when target out of range to be attracted, also get the target by "Expression:TargetUID".
"Condition:End attracting" will be triggered when target out of range to be attracted, also get the target by "Expression:TargetUID".
Target
Call "Action:Update" to update steering force, then get angle of this force by "Expression:ForceAngle", and magnitude by "Expression:ForceMagnitude". Or get this force by "Expression:ForceDx", "Expression:ForceDy".
"Expression:ForceAngle" will be invalided if this target has not been attracted by any source, or this instance is not a "target".
Call "Action:Update" to update steering force, then get angle of this force by "Expression:ForceAngle", and magnitude by "Expression:ForceMagnitude". Or get this force by "Expression:ForceDx", "Expression:ForceDy".
"Expression:ForceAngle" will be invalided if this target has not been attracted by any source, or this instance is not a "target".
"Condition:Begin attracted" or "Condition:End attracted" will be triggered when beginning attracted by source, or target out of range to be attracted. Get source by "Expression:SourceUID".
Update without tag system
Sample capx
It might be hard to assign tag in some complex cases. This behavior provide another way to calculate steering force directly, without tags classification.
Sample capx
It might be hard to assign tag in some complex cases. This behavior provide another way to calculate steering force directly, without tags classification.
- Call "Action:Clean" to clean the steering force to 0
- Call "Action:Attracted by source" to accumulate steering force from current SOL manually. These source instances will also be filtered by "Sensitivity range" property.
- Get angle of this force by "Expression:ForceAngle". Then apply it in your character.
In this mode, "Condition:Begin attracting", "Condition:End attracting", and "Condition:Begin attracted" , "Condition:End attracted" will not be triggered. Use "Condition:Has attracting" to get current attracting sources, and "Condition:Has been attracted" to get attracted targets directly.