Question About Collision Times Recording
Posted: 02 Nov 2021, 10:06
Hello,
I created a scene contained a car and walls. And I can used a joystick to control the car. I want to record the collision times of the car and walls, which means that the car touches with the walls once, the collision time increased by one. But in my scene, when the car touch with walls once, the collision times increased constantly, unless the car leave the walls. Please tell me how to solve this problem and achieve my goal, thanks! The code is following:
I created a scene contained a car and walls. And I can used a joystick to control the car. I want to record the collision times of the car and walls, which means that the car touches with the walls once, the collision time increased by one. But in my scene, when the car touch with walls once, the collision times increased constantly, unless the car leave the walls. Please tell me how to solve this problem and achieve my goal, thanks! The code is following:
Code: Select all
collisionTimes=0
local current_state=sim.checkCollision(car,wall)
if(current_state==1 )then --record state collision times
simUI.show(ui) --remind the collision
collisionTimes=collisionTimes+1
else
simUI.hide(ui) --closed the reminder
end