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.
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
Iâm not sure, sorry.
Iâm not that great. Thanks though.
Ye you great!
No problème
- No, not that I know of.
- Possibly.
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.
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.
I know how to do the colissions but it has lots of lag!
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.
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.
I think they would know about the âWhen ( ) bumps ( )â when already.
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
Wow! Thanks, that is exactly what I needed!
I use that all the time
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!
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â
Thanks everyone! This will be helpful.
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
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.