Commit fc09b79e authored by Chae Ho Shin's avatar Chae Ho Shin

collision working close #40

parent 0ebc1544
......@@ -2109,7 +2109,7 @@ MonoBehaviour:
PathColliderPrefab: {fileID: 8684657376034186961, guid: bf9de3c1290fd0749b383f44c1e706f8,
type: 3}
playercamera: {fileID: 1661408489}
levelManager: {fileID: 0}
levelManager: {fileID: 279236944}
background: {fileID: 1713675715}
velocityslider: {fileID: 260633610}
ui: {fileID: 394305455}
......
......@@ -410,8 +410,8 @@ MonoBehaviour:
- "\u3147\u3147"
winstate: 0
DoubleClickMove: 1
PathRanderMove: 0
WASDMove: 0
PathRanderMove: 1
WASDMove: 1
Todo:
--- !u!1 &332710466
GameObject:
......@@ -782,7 +782,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 394305454}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4cac6e9f5a929c3459ede6049a34ff3b, type: 3}
m_Name:
......@@ -1210,8 +1210,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d21dcedb7a777274ab532991e3f871d8, type: 3}
m_Name:
m_EditorClassIdentifier:
objectType: 4
collisionPreset: 3
objectType: 1
collisionPreset: 4
beta: 0
alpha: {x: 0, y: 0, z: 0}
v: {x: 0, y: 0, z: 0}
......@@ -1220,7 +1220,7 @@ MonoBehaviour:
gamma: 1
time: 0
theobject: {fileID: 535323107}
mass: 10
mass: 1
--- !u!4 &535323109
Transform:
m_ObjectHideFlags: 0
......@@ -1541,7 +1541,7 @@ MonoBehaviour:
gamma: 1
time: 0
theobject: {fileID: 1320474661}
mass: 10
mass: 1
background: {fileID: 1713675711}
uiManager: {fileID: 394305455}
--- !u!4 &739347347
......@@ -2108,7 +2108,7 @@ MonoBehaviour:
PathColliderPrefab: {fileID: 8684657376034186961, guid: bf9de3c1290fd0749b383f44c1e706f8,
type: 3}
playercamera: {fileID: 1661408489}
levelManager: {fileID: 0}
levelManager: {fileID: 279236944}
background: {fileID: 1713675715}
velocityslider: {fileID: 260633610}
ui: {fileID: 394305455}
......@@ -3043,8 +3043,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d21dcedb7a777274ab532991e3f871d8, type: 3}
m_Name:
m_EditorClassIdentifier:
objectType: 4
collisionPreset: 3
objectType: 1
collisionPreset: 4
beta: 0
alpha: {x: 0, y: 0, z: 0}
v: {x: 0, y: 0, z: 0}
......@@ -3053,7 +3053,7 @@ MonoBehaviour:
gamma: 1
time: 0
theobject: {fileID: 1094934748}
mass: 10
mass: 1
--- !u!4 &1094934750
Transform:
m_ObjectHideFlags: 0
......
......@@ -8,8 +8,8 @@
public static CollisionType[] Player { get; private set; } = {
new CollisionType(ObjectType.player,true),
new CollisionType(ObjectType.normalobject,true),
new CollisionType(ObjectType.interactive,false),
new CollisionType(ObjectType.clock,false),
new CollisionType(ObjectType.interactive,true),
new CollisionType(ObjectType.clock,true),
new CollisionType(ObjectType.wall,true)
};
......@@ -22,7 +22,7 @@
};
public static CollisionType[] Interactive { get; private set; } = {
new CollisionType(ObjectType.player,false),
new CollisionType(ObjectType.player,true),
new CollisionType(ObjectType.normalobject,true),
new CollisionType(ObjectType.interactive,true),
new CollisionType(ObjectType.clock,true),
......@@ -30,10 +30,10 @@
};
public static CollisionType[] Clock { get; private set; } = {
new CollisionType(ObjectType.player,false),
new CollisionType(ObjectType.player,true),
new CollisionType(ObjectType.normalobject,true),
new CollisionType(ObjectType.interactive,true),
new CollisionType(ObjectType.clock,false),
new CollisionType(ObjectType.clock,true),
new CollisionType(ObjectType.wall,true)
};
......
......@@ -251,7 +251,7 @@ public class FlatlandMovement : MonoBehaviour
public IEnumerator _AcceleratetoConstantVelocityWithoutCorrection(Vector3 dest, float v)
{
Vector3 acceleration = new Vector3(dest.x, 0f, dest.y);
Vector3 acceleration = new Vector3(dest.x, 0f, dest.z);
var tinterval = Constants.alphatinterval;
acceleration = acceleration.normalized;
......@@ -366,29 +366,39 @@ public class FlatlandMovement : MonoBehaviour
tmp = new Vector3(tmp.x, 0, tmp.z);
tmp = tmp.normalized;
tmp = -tmp;
Vector3 otherv = other.v;
double[] tmpx = {0,tmp.x, tmp.z };
double[] tmpv = { Constants.Gamma(other.v.magnitude) * Constants.c, Constants.Gamma(other.v.magnitude) * other.v.x, Constants.Gamma(other.v.magnitude) * other.v.z };
double[] othertmpx = { 0, -tmp.x, -tmp.z };
double[] tmpv = { Constants.Gamma(v.magnitude) * Constants.c, Constants.Gamma(v.magnitude) * v.x, Constants.Gamma(v.magnitude) * v.z };
var direction = V.DenseOfArray(tmpx);
var realdirection = V.DenseOfArray(othertmpx);
var collisionvelocity = V.DenseOfArray(tmpv);
if(otherv.magnitude > 0)
{
direction = Constants.BoostMatrix(otherv) * direction;
collisionvelocity = Constants.BoostMatrix(otherv) * collisionvelocity;
}
if(v.magnitude > 0)
{
direction = Constants.BoostMatrix(v) * direction;
collisionvelocity = Constants.BoostMatrix(v) * collisionvelocity;
realdirection = Constants.BoostMatrix(v) * realdirection;
}
Vector3 realfinalforcedirection = new Vector3((float)realdirection[1], 0, (float)realdirection[2]);
Vector3 finalcollisionforcedirection = new Vector3((float)direction[1], 0, (float)direction[2]);
var finalcollisionvelocitygamma = collisionvelocity[0] / Constants.c;
Vector3 finalcollisionvelocity = new Vector3((float)(collisionvelocity[1] / finalcollisionvelocitygamma), 0, (float)(collisionvelocity[2] / finalcollisionvelocitygamma));
finalcollisionforcedirection = finalcollisionforcedirection.normalized;
realfinalforcedirection = realfinalforcedirection.normalized;
var cosine = SpaceInnerProduct(finalcollisionvelocity.normalized,finalcollisionforcedirection);
var totalenergy = mass * Constants.c * Constants.c + other.mass * Constants.Gamma(finalcollisionvelocity.magnitude) * Constants.c * Constants.c;
var initialmomentum = finalcollisionvelocitygamma * other.mass * finalcollisionvelocity.magnitude;
var totalenergy = Constants.Gamma(finalcollisionvelocity.magnitude) * mass * Constants.c * Constants.c + other.mass * Constants.c * Constants.c;
var initialmomentum = finalcollisionvelocitygamma * mass * finalcollisionvelocity.magnitude;
var a = 4 * (
(initialmomentum * Constants.c * cosine) * (initialmomentum * Constants.c * cosine)
......@@ -418,11 +428,13 @@ public class FlatlandMovement : MonoBehaviour
resultEnergy = (-b - Math.Sqrt((b * b) - 4 * (a) * (c))) / (2 * a); ;
}
resultEnergy = totalenergy - resultEnergy;
var resultvgamma = resultEnergy / (mass * Constants.c * Constants.c);
var resultvbetamagnitude = Math.Sqrt(1.0 - (1.0/resultvgamma));
StartCoroutine(_AcceleratetoConstantVelocityWithoutCorrection(finalcollisionforcedirection,(float)resultvbetamagnitude));
StartCoroutine(_AcceleratetoConstantVelocityWithoutCorrection(realfinalforcedirection,(float)resultvbetamagnitude));
//Debug.Log(collisions.Count);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment