Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
curvedflats
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
6
Issues
6
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Flatland
curvedflats
Commits
12770ec8
Commit
12770ec8
authored
Aug 21, 2019
by
16이진형
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
오브젝트타입마다 서로 충돌할지 설정가능
parent
46db69f0
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
176 additions
and
0 deletions
+176
-0
Test.unity
Assets/Scenes/Test.unity
+6
-0
Collision.meta
Assets/Scripts/Collision.meta
+8
-0
CollisionPreset.cs
Assets/Scripts/Collision/CollisionPreset.cs
+48
-0
CollisionPreset.cs.meta
Assets/Scripts/Collision/CollisionPreset.cs.meta
+11
-0
CollisionType.cs
Assets/Scripts/Collision/CollisionType.cs
+21
-0
CollisionType.cs.meta
Assets/Scripts/Collision/CollisionType.cs.meta
+11
-0
ObjectType.cs
Assets/Scripts/Collision/ObjectType.cs
+16
-0
ObjectType.cs.meta
Assets/Scripts/Collision/ObjectType.cs.meta
+11
-0
FlatlandMovement.cs
Assets/Scripts/FlatlandMovement.cs
+44
-0
No files found.
Assets/Scenes/Test.unity
View file @
12770ec8
...
...
@@ -1098,6 +1098,8 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
0bf826b8a4774ba4b9c6a1cff6925667
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
objectType
:
1
collisionPreset
:
1
beta
:
0
alpha
:
{
x
:
0
,
y
:
0
,
z
:
0
}
v
:
{
x
:
0
,
y
:
0
,
z
:
0
}
...
...
@@ -1419,6 +1421,8 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
9cbe363fdf02257478cb799cdf2190b3
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
objectType
:
0
collisionPreset
:
0
beta
:
0
alpha
:
{
x
:
0
,
y
:
0
,
z
:
0
}
v
:
{
x
:
0
,
y
:
0
,
z
:
0
}
...
...
@@ -2650,6 +2654,8 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
36bd4b20d3bc814459c577f508eda20c
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
objectType
:
2
collisionPreset
:
2
beta
:
0
alpha
:
{
x
:
0
,
y
:
0
,
z
:
0
}
v
:
{
x
:
0
,
y
:
0
,
z
:
0
}
...
...
Assets/Scripts/Collision.meta
0 → 100644
View file @
12770ec8
fileFormatVersion: 2
guid: e0ce320f331cd9349a5fcfac34484b83
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Collision/CollisionPreset.cs
0 → 100644
View file @
12770ec8
namespace
Assets.Scripts.Collision
{
/// <summary>
///
/// </summary>
static
class
CollisionPreset
{
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
.
wall
,
true
)
};
public
static
CollisionType
[]
NormalObject
{
get
;
private
set
;
}
=
{
new
CollisionType
(
ObjectType
.
player
,
true
),
new
CollisionType
(
ObjectType
.
normalobject
,
true
),
new
CollisionType
(
ObjectType
.
interactive
,
true
),
new
CollisionType
(
ObjectType
.
wall
,
true
)
};
public
static
CollisionType
[]
Interactive
{
get
;
private
set
;
}
=
{
new
CollisionType
(
ObjectType
.
player
,
false
),
new
CollisionType
(
ObjectType
.
normalobject
,
true
),
new
CollisionType
(
ObjectType
.
interactive
,
true
),
new
CollisionType
(
ObjectType
.
wall
,
true
)
};
public
static
CollisionType
[]
Wall
{
get
;
private
set
;
}
=
{
new
CollisionType
(
ObjectType
.
player
,
true
),
new
CollisionType
(
ObjectType
.
normalobject
,
true
),
new
CollisionType
(
ObjectType
.
interactive
,
true
),
new
CollisionType
(
ObjectType
.
wall
,
false
)
};
}
/// <summary>
/// etc는 직접 어떻게 정할지 정해줘야함.
/// </summary>
public
enum
PresetType
{
player
,
normalobject
,
interactive
,
wall
,
etc
}
}
Assets/Scripts/Collision/CollisionPreset.cs.meta
0 → 100644
View file @
12770ec8
fileFormatVersion: 2
guid: 5d01750672178874ea2f4e1213fc3b32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Collision/CollisionType.cs
0 → 100644
View file @
12770ec8
using
Assets.Scripts.Collision
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Assets.Scripts.Collision
{
public
struct
CollisionType
{
public
ObjectType
other
;
public
bool
isCollision
;
public
CollisionType
(
ObjectType
other
,
bool
isCollision
)
{
this
.
other
=
other
;
this
.
isCollision
=
isCollision
;
}
}
}
Assets/Scripts/Collision/CollisionType.cs.meta
0 → 100644
View file @
12770ec8
fileFormatVersion: 2
guid: a4077f36a1fb2fb4fb415d9439b9255a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Collision/ObjectType.cs
0 → 100644
View file @
12770ec8
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Assets.Scripts.Collision
{
public
enum
ObjectType
{
player
,
normalobject
,
interactive
,
wall
}
}
Assets/Scripts/Collision/ObjectType.cs.meta
0 → 100644
View file @
12770ec8
fileFormatVersion: 2
guid: 2834fa3d0a508034a94d787cc74c3d3e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/FlatlandMovement.cs
View file @
12770ec8
...
...
@@ -3,9 +3,21 @@ using System.Collections.Generic;
using
UnityEngine
;
using
MathNet.Numerics.LinearAlgebra
;
using
MathNet.Numerics.LinearAlgebra.Double
;
using
Assets.Scripts.Collision
;
using
System
;
public
class
FlatlandMovement
:
MonoBehaviour
{
//충돌처리
[
SerializeField
]
protected
ObjectType
objectType
;
[
SerializeField
]
protected
PresetType
collisionPreset
;
protected
CollisionType
[]
howToCollison
;
protected
bool
toggle
=
false
;
protected
bool
grabbed
=
false
;
...
...
@@ -50,10 +62,32 @@ public class FlatlandMovement : MonoBehaviour
List
<
Hash128
>
collisions
=
new
List
<
Hash128
>();
public
ObjectType
ObjectType
{
get
{
return
objectType
;
}
}
protected
void
Start
()
{
Physics
.
IgnoreLayerCollision
(
0
,
1
);
startScale
=
theobject
.
transform
.
localScale
;
switch
(
collisionPreset
)
{
case
PresetType
.
player
:
howToCollison
=
CollisionPreset
.
Player
;
break
;
case
PresetType
.
normalobject
:
howToCollison
=
CollisionPreset
.
NormalObject
;
break
;
case
PresetType
.
interactive
:
howToCollison
=
CollisionPreset
.
Interactive
;
break
;
case
PresetType
.
wall
:
howToCollison
=
CollisionPreset
.
Wall
;
break
;
case
PresetType
.
etc
:
break
;
default
:
break
;
}
}
protected
void
FixedUpdate
()
...
...
@@ -290,10 +324,20 @@ public class FlatlandMovement : MonoBehaviour
return
;
}
//howToCollison
collisions
.
Add
(
collision
.
gameObject
.
GetComponent
<
ExtrudedMesh
>().
hash
);
FlatlandMovement
other
=
collision
.
transform
.
parent
.
GetComponent
<
FlatlandMovement
>();
CollisionType
type
=
Array
.
Find
(
howToCollison
,
(
x
)
=>
{
return
x
.
other
==
other
.
ObjectType
;
});
if
(!
type
.
isCollision
)
{
//충돌하지 않을시 충돌하지 않음.
return
;
}
Vector3
col
=
(
other
.
v
-
this
.
v
);
var
tmp
=
collision
.
GetContact
(
0
).
normal
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment