Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gadig
four
Commits
804e8c42
Commit
804e8c42
authored
Oct 27, 2016
by
Swado95
Browse files
Updated
parent
67682d2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Assets/Prefabs/Environment/FloorSwitch.prefab
View file @
804e8c42
No preview for this file type
Assets/script/FloorSwitch.cs
View file @
804e8c42
...
...
@@ -3,12 +3,15 @@ using System.Collections;
public
class
FloorSwitch
:
MonoBehaviour
{
//Ignore sprite renderer in file and set image useing first place in list
public
Collider2D
playerCollid
er
;
public
GameObject
play
er
;
public
bool
isSwitchOn
=
false
;
public
Sprite
[]
sprites
;
public
bool
isSwitchBack
=
true
;
private
Collider2D
pCol
;
private
bool
charIsOn
=
false
;
private
SpriteRenderer
spriteRenderer
;
...
...
@@ -16,17 +19,20 @@ public class FloorSwitch : MonoBehaviour {
void
Start
()
{
//Sets sprite to first frame
spriteRenderer
=
GetComponent
<
Renderer
>()
as
SpriteRenderer
;
pCol
=
player
.
GetComponent
<
Collider2D
>();
spriteRenderer
=
GetComponent
<
Renderer
>()
as
SpriteRenderer
;
spriteRenderer
.
sprite
=
sprites
[
0
];
}
void
OnTriggerEnter2D
(
Collider2D
col
)
{
//Debug.Log(
"somthing moving on"
);
//Debug.Log(
col.name
);
if
(
col
==
p
layerCollider
)
if
(
col
==
p
Col
)
{
//Debug.Log("somthing moving on");
//Turns on bool and changes sprite
isSwitchOn
=
true
;
spriteRenderer
.
sprite
=
sprites
[
1
];
...
...
@@ -36,10 +42,11 @@ public class FloorSwitch : MonoBehaviour {
void
OnTriggerExit2D
(
Collider2D
colE
)
{
//Debug.Log("somthing moving off");
if
(
colE
==
p
layerCollider
)
if
(
colE
==
p
Col
&&
isSwitchBack
==
true
)
{
//Debug.Log("somthing moving off");
//Turns off bool and changes sprite
isSwitchOn
=
false
;
spriteRenderer
.
sprite
=
sprites
[
0
];
...
...
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