Week 12
Zhuoran Li - Mon 1 June 2020, 8:22 pm
Modified: Tue 2 June 2020, 9:28 am
Prototype
The prototype now mainly contains three parts.
Scene building
The game scene is simple but when I try to add the bounciness to the objects, something went wrong. As I want to make sure the movements of the ball and racket are different, I give different materials to the objects.(The image is the sketch when I want to figure out the bounciness between different objects.) But this with the friction, the ball did not move as in the real world.
Now, by detecting the collision between rigid bodies, I add force to the ball to make sure it can move. And, because sometimes the ball would stuck in the middle, I give another function of "shaking the table" to make sure the ball would move again.
physical interaction
As the foundation of the game is Pong, I still need to use the process of bouncing the ball. I remain the racket and the ball but change the control mode as mentioned in the concept part. I have tried to use Arduino. While it works fine separately, the movement of the racket slows down when link Arduino to the Unity.
I used an Ultrasonic sensor to detect the distance. While unity gets the data per 0.1 second, I can convert the distance data to speed.
I have tried to use the FixUpdate function instead of Update function as it is a simulation of the real world's physical movement. But it was still not what I want it to be.
Unity has been slowed down.
The next thing I tried is the accelerometer. The tutor mentioned this in the last few weeks but we didn't change the control mode at that time. So the accelerometer did not work fine. However, now, we only need to detect when the mop is moved quickly. As the mobile is installed on the mop, it is quite like shake the mobile. The accelerometer works fine here.
One thing that is really convenient is that I can download the unity app "Unity Remote 5" to my mobile and link my mobile to the PC by a USB wire. Then the computer can read all the data that provide by mobile phone's hardware, including the accelerometer.
Still, it needs to convert the data from distance to speed. But it doesn't need an accurate number. I compare the result to 0.5 to determine whether it moves slowly or quickly.
Core code:
Monster
Yifan has worked on this part. He needs to make sure that every bounce on the monster would change its appearance a little bit.