Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
four
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
31
Issues
31
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
gadig
four
Commits
804e8c42
Commit
804e8c42
authored
Oct 27, 2016
by
Swado95
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated
parent
67682d2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
Assets/Prefabs/Environment/FloorSwitch.prefab
Assets/Prefabs/Environment/FloorSwitch.prefab
+0
-0
Assets/script/FloorSwitch.cs
Assets/script/FloorSwitch.cs
+14
-7
No files found.
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