Hello!
I’ve started recently with game development, and also, with Defold.
After follow all the Starting tutorials, I’m trying to make some modifications in the Camera Example (from here).
The first thing that I tryied was to make the car collide with a box. So, in camera.collection, I create a new Game Object called box, and inside this, box_sprite and a Static Collision Object:
And the same thing for the car (player), but with Kinematic type.
In player.script, I made some changes on the on_message function:
function on_message(self, message_id, message, sender)
if message_id == hash("contact_point_response") then
print("collision")
else
if message_id == hash("left") then
-- Interpolate the steering angle.
self.steer_angle = vmath.slerp(turn_speed, self.steer_angle, max_steer_angle_left)
elseif message_id == hash("right") then
-- Interpolate the steering angle.
self.steer_angle = vmath.slerp(turn_speed, self.steer_angle, max_steer_angle_right)
elseif message_id == hash("up") then
self.acceleration.y = 2
elseif message_id == hash("down") then
self.acceleration.y = -2
end
end
end
I’m getting the collision message from Debug, every time the car hits the box, but the problem it’s that the car pass through the box, and don’t stop…
Could someone please help me to understand what should I do to stop the car when hits the box?
I tried many things before post here, I’ve read the Collision topic in the Manual…
Sorry for this begginer question and for my english…
I’ll be grateful for any help you can provide!
Matheus