Remember me
You are here: HomeForumCyberix3D ForumGeneral Discussioncollision code block not working
Welcome, Guest
Username: Password: Remember me

TOPIC: collision code block not working

collision code block not working 2 years 8 months ago #2868

I have green balls going accross the screen and you are a red ball and I want to make if you hit a green ball you die. but for some reason the stupid collision block isnt working and when i hit a green ball the red circle just slides out of the screen and the game keeps going. my code should be working as i have loop: collision greenball :restart.
The administrator has disabled public write access.

collision code block not working 2 years 8 months ago #2869

  • GODEBEX
  • GODEBEX's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 158
  • Thank you received: 42
You must rectify that the "static" box of the object or player that you want to collide is empty, if there is any value delete it by clicking on the "x" that is next to "static", if the problem is still not corrected check that the green ball has the collision box marked "1".

I hope it worked for you
Last Edit: 2 years 8 months ago by GODEBEX.
The administrator has disabled public write access.

collision code block not working 2 years 8 months ago #2877

i tried that, when you hit the green ball the code doesnt work the red ball just slides off the screen
The administrator has disabled public write access.

collision code block not working 2 years 8 months ago #2878

  • GODEBEX
  • GODEBEX's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 158
  • Thank you received: 42
Are you using physics commands or "increment" command?
The administrator has disabled public write access.

collision code block not working 2 years 8 months ago #2883

Im using Increment
The administrator has disabled public write access.

collision code block not working 2 years 8 months ago #2886

  • GODEBEX
  • GODEBEX's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 158
  • Thank you received: 42
You cannot use increment commands, if you want an object to collide you must use the physics commands, or since you are using increment the other would be to use distance collision following these steps:

drag a loop command inside the enemy and create a variable, "distance" inside the enemy itself, and using the "set" command you use the following formula, of course you must first choose the variable to which you will set the values:

math.distance (x1, y1, z1, x2, y2, z2)
in this case the "x1, y1 and z1" should be replaced by player

example: player.x, player.y, player.z

You will do the same with the rest, only that you will put
(x, y, z)
so you remove the "2" from the formula.

finally it should be something like this:

math.distance (player.x, player.y, player.z, x, y, z)

You must rectify that everything is well written. now use the if command in your case you add it inside the enemy, don't forget that it always goes inside a "loop", now you choose the variable "distance" which is the one to compare and put the value "100" in the corresponding box of In such a way that when this value is not being passed, the ball is eliminated using the "remove" inside the "if", A clarification, the less the distance value, the closer the enemy player will have to be to be eliminated. I hope it's served
Last Edit: 2 years 8 months ago by GODEBEX.
The administrator has disabled public write access.
Time to create page: 0.083 seconds