What do you want to achieve?
I’m aiming for a system similar to Rocket League, where the ball reacts differently depending on which component of the car it hits and how fast the car is moving.
What is the issue?
Even though I’ve created a system that works in a similar way, the ball occasionally behaves incorrectly, such as when I’m travelling forward and strike the ball with the side, the ball slides to the left in an unrealistic manner. What I’m looking for is a dynamic reaction, where if I’m travelling forwards and the ball hits the front at high speed, the ball will fly high in the air, but if I’m moving forward and hit the ball with the top of my car, the ball should have little to no effect.
It might be beneficial for us to see what direction it is moving in rather then the intended direction, as I believe your .Unit may be backwards, causing the ball to move into the striker, and causing unintended movement. To fix this would simply mean putting a negative in front of your .Unit.
Also, this code will not accomplish what you seek with “dynamic reaction” as you stated. You will just need to use physics for that. If you want to ball to be lighter and easy to push around, perhaps so this code isn’t required, you can set custom material properties, and change it’s density.
In the actual code the .Unit is already negative, I just forgot to make it negative in the code I provided. Making it use physics won’t work as well, since I also want the hit to be exaggerated, since the cars don’t travel very fast. Also, since the ball has its NetworkOwner set to nil, even with a density of 0.01 it wont react to a car hitting it, instead it will stop the car.
If you want it to work properly, it would be akin to coding your own physics. If your down to do try it, then sure. Don’t know if it would fix the problems stated earlier with network replication and such though.