Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GameDevWeek
Wintersemester 2018-2019
Unity
Suck It
Commits
39448712
Commit
39448712
authored
Mar 27, 2019
by
Michael But
Browse files
Objekt mit Slide Effekt
parent
6ca6e586
Changes
2
Hide whitespace changes
Inline
Side-by-side
Assets/_Game/Scripts/Elements/SliderObject.cs
0 → 100644
View file @
39448712
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
SliderObject
:
MonoBehaviour
{
private
Rigidbody2D
rb
;
public
float
force
;
private
void
OnTriggerEnter2D
(
Collider2D
collision
)
{
if
(!
GetComponent
<
Rigidbody2D
>())
{
rb
=
GetComponent
<
Rigidbody2D
>();
}
else
{
Debug
.
Log
(
"Kein Rigidbody"
);
}
if
(
collision
.
gameObject
.
CompareTag
(
"Water"
))
{
if
(
collision
.
transform
.
position
.
x
>
GetComponent
<
Transform
>().
position
.
x
)
{
rb
.
AddForce
(
new
Vector2
(-
force
,
0
));
}
else
if
(
collision
.
transform
.
position
.
x
<
GetComponent
<
Transform
>().
position
.
x
)
{
rb
.
AddForce
(
new
Vector2
(
force
,
0
));
}
}
}
}
Assets/_Game/Scripts/Elements/SliderObject.cs.meta
0 → 100644
View file @
39448712
fileFormatVersion: 2
guid: d5c135c3fe901cf4696abeebd2ac1f28
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Write
Preview
Supports
Markdown
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