In my game, you can shoot these arrows and when they hit a wall, they stick to it. But as you can see here: Imgur: The magic of the Internet , every time an arrow hits the wall, it hits it differently, some disappear inside it and others don’t even touch it. I’ve tried a lot of things, using OnTriggerEnter function with the collision detections set as continuous, raycasting(the one used in the example), and translation with raycasting(that showed the best results). But even so, the collisions are still not constant. Any thoughts on what I can do or if there’s something to be done?
It really should be constant to my understanding of how the functions are working. How exactly are you stopping your arrow? Maybe post the relevant script (insider a code tag if you do).
Since you only seem to care about the Y coordinate, you could record the Y at time of collision, disable the collider and override movement to place the arrow exactly where you want it, but that would potentially look off in motion. Really, it shouldn’t be inconsistent like that as far as I know, unless you’re doing something in the update timing instead of the fixedupdate timing (which colliders and their associated functions are all supposed to be part of).
Using the OnTriggerEnter method, I tried changing the rigidibody body type or just setting the rigidibody velocity to zero, neither of them showed the desired results
private void OnTriggerEnter2D(Collider2D other)
{
EnemyBase enemy = other.gameObject.GetComponent<EnemyBase>();
//rb.velocity = Vector2.zero;
//rb.bodyType = RigidbodyType2D.Static;
Debug.Log(other.name);
if(enemy != null)
{
enemy.TakeDamage(damage);
}
}