73 changed files with 272 additions and 503 deletions
Binary file not shown.
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 3f7585d4a547a6e4191719736d0daf78 |
||||
|
timeCreated: 1463417062 |
||||
|
licenseType: Free |
||||
|
NativeFormatImporter: |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -1,7 +1,7 @@ |
|||||
fileFormatVersion: 2 |
fileFormatVersion: 2 |
||||
guid: 713d19245f9f01349b61eade4b876d9b |
guid: 1ab5a05df27fed64291f5d2341f929b7 |
||||
folderAsset: yes |
folderAsset: yes |
||||
timeCreated: 1463261964 |
timeCreated: 1463416934 |
||||
licenseType: Free |
licenseType: Free |
||||
DefaultImporter: |
DefaultImporter: |
||||
userData: |
userData: |
||||
Binary file not shown.
@ -0,0 +1,78 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 092e42aed3ea51d49b61711bd48284fe |
||||
|
timeCreated: 1463416939 |
||||
|
licenseType: Free |
||||
|
ModelImporter: |
||||
|
serializedVersion: 19 |
||||
|
fileIDToRecycleName: |
||||
|
100000: //RootNode |
||||
|
400000: //RootNode |
||||
|
2300000: //RootNode |
||||
|
3300000: //RootNode |
||||
|
4300000: Cube |
||||
|
7400000: Default Take |
||||
|
9500000: //RootNode |
||||
|
materials: |
||||
|
importMaterials: 0 |
||||
|
materialName: 0 |
||||
|
materialSearch: 1 |
||||
|
animations: |
||||
|
legacyGenerateAnimations: 4 |
||||
|
bakeSimulation: 0 |
||||
|
resampleRotations: 1 |
||||
|
optimizeGameObjects: 0 |
||||
|
motionNodeName: |
||||
|
animationImportErrors: |
||||
|
animationImportWarnings: |
||||
|
animationRetargetingWarnings: |
||||
|
animationDoRetargetingWarnings: 0 |
||||
|
animationCompression: 1 |
||||
|
animationRotationError: 0.5 |
||||
|
animationPositionError: 0.5 |
||||
|
animationScaleError: 0.5 |
||||
|
animationWrapMode: 0 |
||||
|
extraExposedTransformPaths: [] |
||||
|
clipAnimations: [] |
||||
|
isReadable: 1 |
||||
|
meshes: |
||||
|
lODScreenPercentages: [] |
||||
|
globalScale: 1 |
||||
|
meshCompression: 0 |
||||
|
addColliders: 0 |
||||
|
importBlendShapes: 1 |
||||
|
swapUVChannels: 0 |
||||
|
generateSecondaryUV: 0 |
||||
|
useFileUnits: 1 |
||||
|
optimizeMeshForGPU: 1 |
||||
|
keepQuads: 0 |
||||
|
weldVertices: 1 |
||||
|
secondaryUVAngleDistortion: 8 |
||||
|
secondaryUVAreaDistortion: 15.000001 |
||||
|
secondaryUVHardAngle: 88 |
||||
|
secondaryUVPackMargin: 4 |
||||
|
useFileScale: 1 |
||||
|
tangentSpace: |
||||
|
normalSmoothAngle: 60 |
||||
|
normalImportMode: 0 |
||||
|
tangentImportMode: 3 |
||||
|
importAnimation: 0 |
||||
|
copyAvatar: 0 |
||||
|
humanDescription: |
||||
|
human: [] |
||||
|
skeleton: [] |
||||
|
armTwist: 0.5 |
||||
|
foreArmTwist: 0.5 |
||||
|
upperLegTwist: 0.5 |
||||
|
legTwist: 0.5 |
||||
|
armStretch: 0.05 |
||||
|
legStretch: 0.05 |
||||
|
feetSpacing: 0 |
||||
|
rootMotionBoneName: |
||||
|
hasTranslationDoF: 0 |
||||
|
lastHumanDescriptionAvatarSource: {instanceID: 0} |
||||
|
animationType: 0 |
||||
|
humanoidOversampling: 1 |
||||
|
additionalBone: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
Binary file not shown.
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: fead40d50297ab84baf2200692cb99a0 |
||||
|
timeCreated: 1463417014 |
||||
|
licenseType: Free |
||||
|
DefaultImporter: |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,9 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: fa5061d9c09bf974c8583d5e72982fd9 |
||||
|
folderAsset: yes |
||||
|
timeCreated: 1463416939 |
||||
|
licenseType: Free |
||||
|
DefaultImporter: |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
Binary file not shown.
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: e180352f7114a4b4fab550f64fd9271a |
||||
|
timeCreated: 1463416939 |
||||
|
licenseType: Free |
||||
|
NativeFormatImporter: |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -1,204 +0,0 @@ |
|||||
using UnityEngine; |
|
||||
using System.Collections; |
|
||||
using System.Collections.Generic; |
|
||||
namespace Forces |
|
||||
{ |
|
||||
public class Force : System.Object |
|
||||
{ |
|
||||
|
|
||||
public ForceProps properties; |
|
||||
|
|
||||
protected Vector2 goal_vector = Vector2.up; |
|
||||
protected Vector2 last_velocity = Vector2.zero; |
|
||||
protected Vector2 init_in = Vector2.zero; |
|
||||
protected Vector2 init_out = Vector2.zero; |
|
||||
protected Vector2 current_output = Vector2.zero; |
|
||||
protected float init_time = 0.0f; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// last call from velocity method
|
|
||||
/// </summary>
|
|
||||
protected float last_step_time = 0.0f; |
|
||||
/// <summary>
|
|
||||
/// last call from user (like AddForce) to now when start fading out
|
|
||||
/// </summary>
|
|
||||
protected float last_call_time = 0.0f; |
|
||||
|
|
||||
protected float current_delta_step = 0.0f; |
|
||||
protected float current_delta_call = 0.0f; |
|
||||
protected float current_delta_notCall = 0.0f; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// time since init calling
|
|
||||
/// </summary>
|
|
||||
protected float time_calling = 0.0f; |
|
||||
/// <summary>
|
|
||||
/// absolute time since init
|
|
||||
/// </summary>
|
|
||||
protected float time_stepping = 0.0f; |
|
||||
/// <summary>
|
|
||||
/// time since left calling
|
|
||||
/// </summary>
|
|
||||
protected float time_notCalling = 0.0f; |
|
||||
|
|
||||
protected bool killed = false; |
|
||||
|
|
||||
public Force(string id, Vector2 target_direction, float target_speed, float inertia_in = 1.0f, float inertia_out = 1.0f, float impulse = 0.0f) |
|
||||
{ |
|
||||
properties = new ForceProps(id, target_speed, inertia_in, inertia_out, impulse); |
|
||||
|
|
||||
Call(target_direction); |
|
||||
} |
|
||||
public Force(ForceProps props, Vector2 target_direction) |
|
||||
{ |
|
||||
properties = props; |
|
||||
|
|
||||
Call(target_direction); |
|
||||
} |
|
||||
public Vector2 Velocity() |
|
||||
{ |
|
||||
Vector2 delta = Vector2.zero; |
|
||||
Vector2 current_target_velocity = Vector2.zero; |
|
||||
|
|
||||
if (init_time == 0.0f) Initialize(); |
|
||||
|
|
||||
StartStep(); |
|
||||
|
|
||||
current_target_velocity = FadeIn() + FadeOut(); |
|
||||
delta = current_target_velocity; |
|
||||
current_output = Clamp(last_velocity + delta, goal_vector); |
|
||||
|
|
||||
EndStep(); |
|
||||
|
|
||||
return current_output; |
|
||||
} |
|
||||
/// <summary>
|
|
||||
/// called by user to add force
|
|
||||
/// </summary>
|
|
||||
public void Call(Vector2 new_goal_vector) |
|
||||
{ |
|
||||
if (properties.forceMode == ForceMode.Impulse) |
|
||||
Initialize(); |
|
||||
|
|
||||
last_call_time = Time.time; |
|
||||
goal_vector = new_goal_vector.normalized * properties.target_speed; |
|
||||
} |
|
||||
/// <summary>
|
|
||||
/// Determines if the force is being used after reaching zero force
|
|
||||
/// </summary>
|
|
||||
/// <returns></returns>
|
|
||||
public bool Using() |
|
||||
{ |
|
||||
//Wait half a second to check if the velocity is null
|
|
||||
return ((Time.time - last_call_time) < 0.5f || last_velocity != Vector2.zero) && !killed; |
|
||||
} |
|
||||
public void Kill () |
|
||||
{ |
|
||||
last_call_time = 0.0f; |
|
||||
current_delta_call = 0.0f; |
|
||||
current_delta_notCall = 0.0f; |
|
||||
last_velocity = Vector2.zero; |
|
||||
killed = true; |
|
||||
} |
|
||||
/// <summary>
|
|
||||
/// Returns the value of the last call
|
|
||||
/// </summary>
|
|
||||
/// <returns></returns>
|
|
||||
public Vector2 LastVelocity() |
|
||||
{ |
|
||||
return last_velocity; |
|
||||
} |
|
||||
|
|
||||
protected void Initialize() |
|
||||
{ |
|
||||
init_time = Time.time; |
|
||||
} |
|
||||
|
|
||||
protected void StartStep() |
|
||||
{ |
|
||||
///Is the force acting like an impulse? if it is, then stop calling if impulse time < currentTime
|
|
||||
bool impulse = (properties.impulse > 0.0f && Time.time - init_time < properties.impulse); |
|
||||
|
|
||||
current_delta_step = last_step_time == 0.0f ? 0.0f : Time.time - last_step_time; |
|
||||
|
|
||||
if (last_call_time == 0.0f) |
|
||||
{ |
|
||||
current_delta_call = 0.0f; |
|
||||
current_delta_notCall = 0.0f; |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
if (last_step_time - last_call_time > current_delta_step && !impulse) |
|
||||
{ |
|
||||
current_delta_notCall = current_delta_step; |
|
||||
///set a start point to fade velocity
|
|
||||
init_out = last_velocity; |
|
||||
current_delta_call = 0.0f; |
|
||||
time_calling = 0.0f; |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
current_delta_call = current_delta_step; |
|
||||
///set a start point to fade velocity
|
|
||||
init_in = last_velocity; |
|
||||
current_delta_notCall = 0.0f; |
|
||||
time_notCalling = 0.0f; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
time_calling += current_delta_call; |
|
||||
time_stepping += current_delta_step; |
|
||||
} |
|
||||
|
|
||||
protected Vector2 FadeIn() |
|
||||
{ |
|
||||
// float fade_in_fact = 0.0f;
|
|
||||
Vector2 output = Vector2.zero; |
|
||||
|
|
||||
if (current_delta_call <= 0.0f) return Vector2.zero; |
|
||||
|
|
||||
//fade_in_fact = Mathf.Clamp01(time_calling / inertia_in);
|
|
||||
output = (goal_vector - last_velocity) * (current_delta_call / properties.inertia_in); |
|
||||
|
|
||||
return output; |
|
||||
} |
|
||||
protected Vector2 FadeOut() |
|
||||
{ |
|
||||
//float fade_out_fact = 0.0f;
|
|
||||
Vector2 output = Vector2.zero; |
|
||||
|
|
||||
if (current_delta_notCall <= 0.0f) return Vector2.zero; |
|
||||
|
|
||||
//fade_out_fact = Mathf.Clamp01(time_notCalling / inertia_in);
|
|
||||
output = (Vector2.zero - last_velocity) * (current_delta_notCall / properties.inertia_out); |
|
||||
|
|
||||
return output; |
|
||||
} |
|
||||
protected Vector2 Clamp(Vector2 vector, Vector2 max) |
|
||||
{ |
|
||||
float max_magnitude = max.magnitude; |
|
||||
float currentMagnitude = vector.magnitude; |
|
||||
float dot = Vector2.Dot(vector, max); |
|
||||
Vector2 output = vector; |
|
||||
|
|
||||
//check if it is calling to clamp
|
|
||||
if (currentMagnitude > max_magnitude && dot > 0.0f && current_delta_call != 0.0f) |
|
||||
{ |
|
||||
output = max; |
|
||||
} |
|
||||
//checl if is not calling to clamp to zero
|
|
||||
else if (dot <= 0.0f && current_delta_call == 0.0f) |
|
||||
{ |
|
||||
output = Vector2.zero; |
|
||||
} |
|
||||
|
|
||||
return output; |
|
||||
} |
|
||||
protected void EndStep() |
|
||||
{ |
|
||||
last_step_time = Time.time; |
|
||||
last_velocity = current_output; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
@ -1,12 +0,0 @@ |
|||||
fileFormatVersion: 2 |
|
||||
guid: 57b436089801943408c989af783a9a85 |
|
||||
timeCreated: 1455409843 |
|
||||
licenseType: Free |
|
||||
MonoImporter: |
|
||||
serializedVersion: 2 |
|
||||
defaultReferences: [] |
|
||||
executionOrder: 0 |
|
||||
icon: {instanceID: 0} |
|
||||
userData: |
|
||||
assetBundleName: |
|
||||
assetBundleVariant: |
|
||||
@ -1,93 +0,0 @@ |
|||||
using UnityEngine; |
|
||||
using System.Collections.Generic; |
|
||||
|
|
||||
namespace Forces |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Controls forces to be esay for the user to use
|
|
||||
/// </summary>
|
|
||||
public class ForceController : System.Object |
|
||||
{ |
|
||||
protected Dictionary<string, Force> active_forces = new Dictionary<string, Force>(); |
|
||||
protected List<Force2Call> call_forces = new List<Force2Call>(); |
|
||||
protected List<string> null_forces_index = new List<string>(); |
|
||||
|
|
||||
protected Vector2 lastFinalVel; |
|
||||
|
|
||||
public void AddForce(ForceProps forceProps, Vector3 direction) |
|
||||
{ |
|
||||
Force target = Target(forceProps, direction); |
|
||||
call_forces.Add(new Force2Call(direction, target)); |
|
||||
} |
|
||||
|
|
||||
public void DestroyForce (ForceProps forceProps) |
|
||||
{ |
|
||||
Force f = GetForce(forceProps); |
|
||||
if (f == null) return; |
|
||||
f.Kill(); |
|
||||
null_forces_index.Add(forceProps.Name); |
|
||||
} |
|
||||
|
|
||||
public Force GetForce(ForceProps force) |
|
||||
{ |
|
||||
if (active_forces.ContainsKey(force.Name)) |
|
||||
return active_forces[force.Name]; |
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
public Vector2 Update() |
|
||||
{ |
|
||||
Vector2 final_velocity = Vector2.zero; |
|
||||
|
|
||||
///ADD AND CALL STEP
|
|
||||
foreach (Force2Call f in call_forces) |
|
||||
{ |
|
||||
f.force.Call(f.direction); |
|
||||
} |
|
||||
|
|
||||
///APPLY STEP
|
|
||||
foreach (string key in active_forces.Keys) |
|
||||
{ |
|
||||
Force f = active_forces[key]; |
|
||||
|
|
||||
///Add to null forces if the force isnt using
|
|
||||
if (!f.Using()) |
|
||||
{ |
|
||||
null_forces_index.Add(f.properties.Name); |
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
Vector2 add = f.Velocity(); |
|
||||
final_velocity += add; |
|
||||
} |
|
||||
|
|
||||
///CLEAR STEP
|
|
||||
foreach (string i in null_forces_index) |
|
||||
{ |
|
||||
active_forces.Remove(i); |
|
||||
} |
|
||||
|
|
||||
call_forces.Clear(); |
|
||||
null_forces_index.Clear(); |
|
||||
|
|
||||
Vector2 final = final_velocity * Time.deltaTime * 100.0f; |
|
||||
Vector3 out_ = final - lastFinalVel; |
|
||||
lastFinalVel = final; |
|
||||
|
|
||||
return out_; |
|
||||
} |
|
||||
|
|
||||
protected Force Target(ForceProps force, Vector3 direction) |
|
||||
{ |
|
||||
Force out_ = GetForce(force); |
|
||||
|
|
||||
if (out_ == null) |
|
||||
{ |
|
||||
out_ = new Force(force, direction); |
|
||||
active_forces.Add(out_.properties.Name, out_); |
|
||||
} |
|
||||
|
|
||||
return out_; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,12 +0,0 @@ |
|||||
fileFormatVersion: 2 |
|
||||
guid: 114545d266452cb4b96fd2ef86902650 |
|
||||
timeCreated: 1456794068 |
|
||||
licenseType: Free |
|
||||
MonoImporter: |
|
||||
serializedVersion: 2 |
|
||||
defaultReferences: [] |
|
||||
executionOrder: 0 |
|
||||
icon: {instanceID: 0} |
|
||||
userData: |
|
||||
assetBundleName: |
|
||||
assetBundleVariant: |
|
||||
@ -1,63 +0,0 @@ |
|||||
using UnityEngine; |
|
||||
using System.Collections; |
|
||||
|
|
||||
namespace Forces |
|
||||
{ |
|
||||
public enum ForceMode { Force, Impulse, Aceleration } |
|
||||
/// <summary>
|
|
||||
/// Label force static information
|
|
||||
/// </summary>
|
|
||||
[System.Serializable] |
|
||||
public struct ForceProps |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// indetify instance id
|
|
||||
/// </summary>
|
|
||||
public string Name; |
|
||||
/// <summary>
|
|
||||
/// inertia value when starts in seconds (fade in)
|
|
||||
/// </summary>
|
|
||||
public float inertia_in; |
|
||||
/// <summary>
|
|
||||
/// inertia value when ends in seconds (fade out)
|
|
||||
/// </summary>
|
|
||||
public float inertia_out; |
|
||||
/// <summary>
|
|
||||
/// time calling without Update
|
|
||||
/// </summary>
|
|
||||
public float impulse; |
|
||||
/// <summary>
|
|
||||
/// goal speed
|
|
||||
/// </summary>
|
|
||||
public float target_speed; |
|
||||
/// <summary>
|
|
||||
/// mode of applying this force
|
|
||||
/// </summary>
|
|
||||
public ForceMode forceMode; |
|
||||
|
|
||||
|
|
||||
public ForceProps(string Name, float target_speed, float inertia_in = 1.0f, float inertia_out = 1.0f, float impulse = 0.0f) |
|
||||
{ |
|
||||
this.Name = Name; |
|
||||
this.target_speed = target_speed; |
|
||||
this.inertia_in = inertia_in; |
|
||||
this.inertia_out = inertia_out; |
|
||||
this.impulse = impulse; |
|
||||
this.forceMode = impulse > 0.0f ? ForceMode.Impulse : ForceMode.Force; |
|
||||
} |
|
||||
} |
|
||||
/// <summary>
|
|
||||
/// Target force and new vector to apply
|
|
||||
/// </summary>
|
|
||||
public struct Force2Call |
|
||||
{ |
|
||||
public Vector3 direction; |
|
||||
public Force force; |
|
||||
|
|
||||
public Force2Call(Vector3 direction, Force force) |
|
||||
{ |
|
||||
this.direction = direction; |
|
||||
this.force = force; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,12 +0,0 @@ |
|||||
fileFormatVersion: 2 |
|
||||
guid: 2f6cb937bd9326148b7ab27db4d1d775 |
|
||||
timeCreated: 1456794126 |
|
||||
licenseType: Free |
|
||||
MonoImporter: |
|
||||
serializedVersion: 2 |
|
||||
defaultReferences: [] |
|
||||
executionOrder: 0 |
|
||||
icon: {instanceID: 0} |
|
||||
userData: |
|
||||
assetBundleName: |
|
||||
assetBundleVariant: |
|
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 60d552ec687c4b145a91814cb030cb35 |
||||
|
timeCreated: 1463417594 |
||||
|
licenseType: Free |
||||
|
DefaultImporter: |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue