#Bullet Problem
1 messages · Page 1 of 1 (latest)
Only 1 will work
why wouldnt 2 work?
Reflect is for things like Raycasts
make bullet follow raycast?
It can’t get normal colliders
not possible?
No
damn
Unless you wanna write like 1476 lines of code
everything for my bulllets
Nah it’s not possible is what I’m saying
lol
gotcha
and the 3 option?
why not?
performance?
or do I not completly understand OverlapSphere?
I asked that question some time ago
About the ray thing
It’s not gonna work
I have an idea
The only thing close to my answer was the raycast
You’re gonna have to focus a lot cuz it’s a bit hard to explain
what is?
oh your idea
im all ears
So the problem is that the enemy bullet hits the player and it bumps him back right?
yessir
goddamn thats long
but take your time
So, you can make
The main Trigger bullet the parent of the Collider bullet
So the trigger bullet is a bit bigger than the collider bullet
The collider bullet is the one that can make it actually collide with walls and bounce
But if the trigger bullet detect the player, it deleted it self, which will also delete the collider bullet (since it’s the parent)
The trigger bullet is invisible
nice plan
however
Wait hold on the meeee
U see the speed,
IF its is trigger , it would need to be much bigger then collider
and that faces another problem
the bullet hits before actually touching the player
Trigger Bullet (Parent, the bullet with the script)
-Collider bullet (Simple allows it to collide)
so dodgeing wont be so fun lmao
Hmmm
You sure it would need to be that much bigger?
You should still try
not sure im gonna test
however rn I cant I have to do some math homework
Rip
So I tested your idea
doesnt work sadly
However I have another idea
I combine a prediction script I found with your idea
The prediction script predicts the bullet and if it phases trough the player it is put back inside the player.
If I manage to change the prediction so that it is always off by the distance of the is trigger collider of the bullet , then it should work
Problem being , idk how to manage it
.
.
.
So after some testing
I have come to this
private void FixedUpdate()
{
StartCoroutine(Predict());
}
IEnumerator Predict()
{
Vector3 prediction = transform.position + rb.velocity * Time.fixedDeltaTime;
RaycastHit hit2;
int layerMask =~ LayerMask.GetMask("Bullet");
if(Physics.Linecast(transform.position, prediction, out hit2, layerMask))
{
transform.position = hit2.point;
rb.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative;
rb.isKinematic = true;
yield return 0;
OnTriggerEnter(hit2.collider);
}
}
This has weirdly kinda solved the problem,
- Player doesnt get pushed anymore if standing still
- Player still gets interuped if walking in bullet
- Bullet doesnt bounce anymore cause it gets teleported by the prediction in the player
Since I am not going anywhere
I might switch my enemy bullets to is trigger
However I am still waiting for hope
What if you make the player have a trigger object around him and it detects bullets?
Tried wont work
Imma stick to isTrigger bullets
on enemys
cause I cant make any so smart to predict the player and reflect bullets off of walls
Fun fact , my whole project got corupped because of that bullet that cloned itself
.
.
The reason it crashed is cause I want to make it so that the bullet splits above the player/enemy
And I used a raycast
And when raycast hit it would clone
little did I know , a raycast shoots super fast even if the bullet is above for a split second
Any ideas to make this work?
( now I learned to do back ups )
Raycasts are instant
Well then
Wth happend?
Imma send script in a sec
private void FixedUpdate()
{
if (Physics.Raycast(transform.position, Vector3.down, Mathf.Infinity, whatIsPlayer) && rayCastHtAlr == false)
{
rayCastHtAlr = true;
coolCloning();
}
}```
coolCloning is when the bullet explodes into more
Nice
So um
How can I make it so that coolCloning only activates once?
I cant really explain what is causing it do it more then one time , since my pc crashes after that actually happens
so after all this time I fixed the bouncy bullet problem
now all I have to do is fix the cool cloning bullet
How’d you fix it
So um
Started a way to predict where the bullet would land , and move the bullet in that place before it passes it
by passing means it goes so fast , 1 frame is in front of wall , next frame is behind wall
which meant no collision
but I fixed this via the prediction
and once it gets moved to the position of the impact
I calculate the new velocity after the bounce via Vector3.Reflect
And change the velocity of the rigidbody to that ( exactly when it gets moved to the position of the impact )
Hope u understand me
( if u want code , I can send )
@cerulean igloo continue here
so
Have you heard of collision detection?
bullet affects movemnet , when the player head in into the bullet he doesnt just take damage he also stops for seconds because of the collision
Yes and I have a vague idea
Can you spawn the bullet a bit more far from the player?
why?
So he doesn’t hit it
it doesnt spawn in him
its in a gun a bit far away from the player collider
So he runs in the bullet?
oh no
when the enemy
shoots
and he runs into the bullets
( that also was a problem lmao )
like your selection of words, but what is him and slide out means phase?
So it hits the gun or the player body itself?
Maybe show a video
sure gemme a sec
so lets get one concept clear, when you talking about the whole process of "shooting" in normal shooting games.
you are talking about
- player shoot a bullet
- bullet "hits" something
2.5 bullet send message to scripts - bullet dissappear
- effect is spawned
pretty much ,yes
i assume in ur shooting games, u dont want ur bullet NOT DISSAPPEAR after it hits target
u want it to dissappear
yessir
but it doesnt, it penetrates players and keep travelling
so that is what i called slide out, from players
I will send it with the onCollision
Using Trigger is a bandaid solution for this, especially when bounciness is the main part of the bullet
yes but how can I make so that it send a message at collision without collision
I just cant another way exept isTrigger
I will accept any other function solutions
Put the bullet to speculative dynamic, it will detect collision properly
You can’t check collision in a dif way
Getting pushed by the bullet
thats my issue with OnCollisionEnter
Is that the enemy bullet?
Can’t tell, it looks like it’s coming from the enemy
yes
Try putting the bullet mass to 0
(It will make it a tiny mass)
But that doesn’t look like much of an issue
You can destroy the bullet after the hit
its a beam
ig its the object moveing INREDIBLY fast
and I cant do that I get a weird number
It’s ok
1e-07
The weird number is a super tiny number
7 zeros I think
think
I see
but now its even worse
hold on
what should the bullet rigidbody look like?
Ok nvm if it’s worse
Wdym?
Is the bullet deleted after the hit?
Interpolate / CollisionDetection
ther is no hit
just a ray
Oh
Then in the ray script theres something that applies force to the ray hit object
not a raycast , the bullet and its trail look like one
because of how fast its going i think
Oh alr lol
It will still bump the player if its slow
well then , what should I do?
Hmmm
What if you increase player mass
And decrease bullet mass
the slow down still kinda happens
my whole point is to exterminate it
Yeah ik
I wonder if collision detection still works with Ignore Collision
That could work if it does
Ignore Collision?
Yes
But the main problem is that I’m unsure if it will detect collision still
Detect OnCollision