update: 2017/03/23
reference:
1. Plugin UE4Duino - Arduino to UE4 plugin Release!
2. UDK - UE4Duino Plugin
3. loveunrealengine | TIPS
A. 系統環境:
OS: Windows 8
UE: UE 4.10
-----------------------------------------------------------------------------------------------
B. Arduino
1. 將 Arduino 連上電腦, 確認 COM port 的號碼(在此為 4)
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(random(1, 100));
delay(1000); // wait for a second
}
-----------------------------------------------------------------------------------------------
C. Unreal Engine
1. 到 Plugin UE4Duino - Arduino to UE4 plugin Release! 下載檔案:
UE4Duino_4_10.zip , 解壓縮後得到 UE4Duino 資料夾
2. 新增空白的 UE 專案: UE4Duino_01, 在專案下新增 Plugins 資料夾, 並將剛剛的
UE4Duino 資料夾放入.
4. 進入 UE4Duino_01 專案的 Level Blueprint, 在 Event Graph 修改如下:
回到 Level Editor, 在 Content Browser 存檔(Save All) 後, Build -> Play
-----------------------------------------------------------------------------------------------
D. Turn the LED on /off
1. Arduino:
int led = 13; // LED pin number
String content = "";
char character;
void setup() {
Serial.begin(9600);
// initialize digital pin 13 as an output.
pinMode(led, OUTPUT);
delay(1000);
Serial.println("setup ok");
}
void loop() {
delay(100); // delay in between reads for stability
// UE4 Input
while(Serial.available() > 0)
{
character = Serial.read();
if(character != '^') {
content.concat(character);
}
else {
if (content == "ON") {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
Serial.println("turn the LED on");
}
else if(content == "OFF") {
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
Serial.println("turn the LED off");
}
content = "";
} // end of else
} // end of while
}
2. Unreal
按下: o 鍵 ---> Serial Opened
h 鍵 ---> turn the LED on // HIGH is the voltage level
l 鍵 ---> turn the LED off // making the voltage LOW
c 鍵 ---> Serial Closed
-----------------------------------------------------------------------------------------------
E. UE4Duino 2.0
1. Arduino:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
//Serial.println(random(1, 100));
//Serial.print("#");
Serial.print(random(1, 100)); // not need use Serial.println
//Serial.println("#");
delay(1000); // wait for a second
}
2. Unreal:
hey i have a question ... you just simulated in the blueprint ? you didnt insert a acton? because when i run the blueprint the modules didnt nothing explain me, thanks !
回覆刪除Hi, have you checked UE4Duino Plugin is enabled? (checkbox is checked)
回覆刪除yeah the plugin is active i checked the enable, any idea where else?
回覆刪除1. Your Arduino's Serial output may not analyzed correctly by Unreal. You may try simple Serial.print from Arduino, ex: only char or string but not use println.
回覆刪除2. And if you use PintString output to screen in Unreal, especially in VR Mode, you may need to let PintString keep more time(I always set 30 second), because the PintString message is slow down to show.
OK! thank you so much !...i will do it step by step hehe but my printString is not for VR Mode i use it only for my Print string Arduino and i hope see the char in the graphic window :)
回覆刪除Hey friend i have a question in your finally blueprint ... i have problems with the keyboard can you help me because when i want pressed for example O for open serial didn't nothing, explain me thanks :)
回覆刪除1. Replace the "Event BeginPlay" node to "O" Key node
回覆刪除2. Don't forget to close COM in "Event EndPlay" node
3. If it don't works, unplug Arduino & plugin it again.
OK! thank you so much :D
回覆刪除