I faced a challenge that unfortunately I can’t solve this problem
I designed some balls that change their path and rotate when they hit the screen
But I wanted to create an obstacle between them so that when they hit that obstacle, their path will be diverted
Unfortunately, I do not know how to solve this problem
I tried to do this with the intersection method, but I didn’t succeed
I tried to create a small plane as a barrier and a wall in the middle of the screen, but it didn’t work
Balls.arexport (3.8 MB)
There is a lot of stuff going on in that project. I have some general advice on how you can start to modify it to make it simpler, more performant, and easier to add collisions to.
First, I recommend tracking velocity and position separately, then adding them together to get the position. This will give you the flexibility to add acceleration too, if you want. It’s just another layer that adds into velocity instead of position.
Here is an example of how you might start to implement circular collisions.
I recommend dealing with normalized values for screen-space stuff, and then convert them into world space / focal plane after doing most of the processing. It just makes everything a little easier to understand during development.
The step after that would be to determine how you want this event to affect the velocity (it could be hard collision, soft repulsion, gravity well, etc).
In general, if you want to get more familiar with building a physics system in spark, here’s an article that shows how to make some spring physics. Mostly, the concepts behind velocity will apply to your project.
One more thing I suggest is to deal with vectors instead of split values like you have. It will be faster and more flexible in the end.
Thank you for your explanation, but due to the complexity of the effect, I wish you would create this obstacle for one of the balls
It was definitely easier to learn by example
Because in fact, I wanted to enter the second stage by learning this physics model and the collision of the ball with the obstacle, and I started to design the physics of the collision of the balls with each other. Thank you again for your explanation and I will try to complete this effect
It was done but it is very complicated
Nice work! Physics usually require a lot of loops, so it is a little more flexible in script, but it’s nice that we can manage some basic stuff in patches.