One-Block point towards and Lagless when bumps

help

#1

Is there a way to make an object point towards somthing using just one block? And is there a way to detect when something touches something else when there are lots of clones and without lag? Thanks.
@CodeHelp.


#2

Game starts-
Set position X(object’s self X position —number) Y (self Y position)

This prob didn’t help, because you an amazing coder and you’re WAY better than me at this lol


#3

I’m not sure, sorry.


#4

I’m not that great. Thanks though.


#5

Ye you great!
No problème


#6
  1. No, not that I know of.
  2. Possibly.

#7

Is there a way to make an object point towards somthing using just one block?

Yes.

If you look in my Rubik’s Cube project, you’ll find some abilities called ATAN2. It has 2 nested conditionals, so it isn’t literally 1 block. But each code path has only one block, so if you’re worried about lag, it executes in the same time as one block. Change the blocks to Set Angle.

A single equation, without the nested conditionals, can also be derived using Dot Product if you really need just 1 block.

And is there a way to detect when something touches something else when there are lots of clones and without lag?

Yes. There’s been other topics/discussions about this. In general, you’d create either a circular or square zone (depending on the image shape) that triggers a When < rule.


#8

See my games like Zombie Run and Flight of the Turkey.
I mainly use square collisions where absolute value (obj_x-obj2_x)<(hitboxwidth) and same with Y values. You’ll have to test the hitbox a few times though. Zombie Run has ~250 objects and most of my other games has 30 objects.


#9

I know how to do the colissions but it has lots of lag!


#10

Thanks! That is really helpful, but I have lots and lots of clones which need to test if they are touching any other clones simultaneously. I don’t think that that would quite work.

Edit: There are lots of ‘ATAN2’s and they all require a check if else. What I was trying to say was that I needed a single block as in a single ‘set angle’ block.


#11

Why do you need 1 Set Angle block? Read this again:

I can give you a formula for 1 Set Angle block but it won’t change anything.


#12

I think they would know about the “When ( ) bumps ( )” when already.


#13

clones which need to test if they are touching any other clones simultaneously

For that you need to use the built in When Bump rule and accept the lag


#14

Wow! Thanks, that is exactly what I needed!


#15

I use that all the time


#16

Well I just made a project and I used Jeff3321🇳🇱‘s code and I did this


Check the “collisions” rule in “square 2”!
@MISSION_IMPOSSIBLE hope this helps!


#17

Me too! I used it for tons of projects, and I learned how to do it by checking a game in featured, I think it was something like “target practice”


#18

Thanks everyone! This will be helpful.


#19

Hmmm… I am just wondering… is there a way to do a move forward without changing the angle? I need a way to use a set position block to move lots of objects in lots of different directions without changing the angle of the object.
@CodeHelp


#20
Set Position X [ (self)speed/40 * COS((self)angle) + (self)x_position ], Y [ (self)speed/40 * SIN((self)angle) + (self)y_position ]

where, (self)angle is a new object variable that you set instead of changing the object’s rotation

note: Speed is divided by 40 since the a Speed of 400 moves 10 pixels each frame with the Move Forward block.