Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
add TouchSensor on PointerCliced
Browse files Browse the repository at this point in the history
  • Loading branch information
esm-tmori committed Jul 19, 2020
1 parent 86a5079 commit a74f062
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions Assets/Scripts/Hakoniwa/Assets/EV3/RobotController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ private void UpdateActuator()
this.motor_b.SetTargetVelicty(power_b * powerConst);
if (this.motor_arm != null)
{
//Debug.Log("moter_c:" + power_c);
this.motor_arm.SetTargetVelicty(power_c * this.armMotorConst);
}
}
Expand Down
17 changes: 16 additions & 1 deletion Assets/Scripts/Hakoniwa/Assets/EV3/TouchSensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
using System.Collections.Generic;
using UnityEngine;
using Hakoniwa.Assets;
using UnityEngine.EventSystems;

public class TouchSensor : MonoBehaviour, IRobotTouchSensor
public class TouchSensor : MonoBehaviour, IRobotTouchSensor, IPointerDownHandler, IPointerUpHandler
{
private GameObject touchSensor;
private bool isTouched;
Expand Down Expand Up @@ -32,4 +33,18 @@ private void OnTriggerExit(Collider other)
this.isTouched = false;
//Debug.Log("NotPressed");
}


void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
{
this.isTouched = true;
//Debug.Log("Pressed");
}


void IPointerUpHandler.OnPointerUp(PointerEventData eventData)
{
this.isTouched = false;
//Debug.Log("NotPressed");
}
}
3 changes: 2 additions & 1 deletion Assets/Scripts/Hakoniwa/Assets/HackEV/HackEVParts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class HackEVParts : MonoBehaviour, IEV3Parts
private string ultra_sonic_sensor = "RoboModel_Axis/HackEV_L8_Sidewinder_Head/EV3_UltrasonicSensor/EV3_UltrasonicSensor_Bk10";
private string gyro_sensor = "RoboModel_Axis/HackEV_L8_Sidewinder_Head/EV3_GyroSensor/EV3_GyroSensor_Ash01";
private string motor_arm = "RoboModel_Axis/HackEV_L8_MiddleMotor/EV3_InteractiveServoMotor_L/EV3_InteractiveServoMotor_L_MotorRoot";
private string touch_sensor = "RoboModel_Axis/HackEV_L9_Sidewinder_ShoulderSensor/HackEV_L8_TouchSensor2/L8_DoubleBevelGear20_Bk 1";

public string GetColorSensor()
{
Expand All @@ -36,7 +37,7 @@ public string getUltraSonicSensor()
}
public string getTouchSensor()
{
return null;
return touch_sensor;
}

public string getGyroSensor()
Expand Down

0 comments on commit a74f062

Please sign in to comment.