if(!bulletinside)
{
rigidbody.drag= 1;
bulletSpd=200.0f;
rigidbody.AddForce(transform.forward * bulletSpd);
}
if(bulletinside)
{
if(freeze !fastforward !slow)
{
rigidbody.drag= 1;
bulletSpd=0.0f;
rigidbody.AddForce(transform.forward * bulletSpd);
}
else if(fastforward !slow !freeze)
{
rigidbody.drag= 1;
bulletSpd= 2000.0f;
rigidbody.AddForce(transform.forward * bulletSpd);
}
else if(slow !fastforward !freeze)
{ Debug.Log ("Collided");
bulletSpd=100.0f;
rigidbody.AddForce(transform.forward * bulletSpd );
rigidbody.drag= 10.0f;
}
else
{
Debug.Log ("NotCollided");
rigidbody.drag= 1;
bulletSpd=200.0f;
rigidbody.AddForce(transform.forward * bulletSpd);
}
}
}
Drag is only gonna have so much effect when you are constantly adding force
Is there any way slow down a normal addforce
You could increase drag. why are you using 1 specifically?
Why not use velocity instead force? Also have you played with mass?
I have increase addforce but it will eventually stop which I do not want
I do not wish to use mass to make it complicated
I thought your problem was that the drag was not slowing down your object, but you don’t want it to stop either?
I tried a new solution to make it stop immediately and it works but how do I set it back to normal speed when it is not bulletinside
if(!bulletinside)
{
bulletSpd=50.0f;
rigidbody.AddForce(transform.forward * bulletSpd);
}
if(bulletinside)
{
if(freeze !fastforward !slow)
{
bulletSpd=0.0f;
rigidbody.AddForce(transform.forward * bulletSpd);
}
else if(fastforward !slow !freeze)
{
bulletSpd= 2000.0f;
rigidbody.AddForce(transform.forward * bulletSpd);
}
else if(slow !fastforward !freeze)
{
bulletSpd = 0.0f;
bulletSpd= 0.05f;
// rigidbody.drag += 0.5f;
//// Debug.Log (rigidbody.drag);
// rigidbody.AddForce(transform.forward *= bulletSpd);
}
// else if(!slow !fastforward !freeze)
else
{
bulletSpd=50.0f;
rigidbody.AddForce(transform.forward * bulletSpd);
}
}
}
You can try changing the RB’s velocity directly (rigidbody.velocity). Save the value it had before ‘bulletinside’ and then restore after it’s not ‘bulletinside’ anymore.
I’m a bit curious here. What are you trying to achieve?
I am trying to achieve when hit by slow it will slowdown and when it is not being slow it will go back to it original speed,The problem I faced is bullet stuck halfway when being slowed and not regaining to it original speed when it is not being slowed
How do I go back to the original speed after slowing down.This is my current code and it is not going back to the original speed after slowing down.
void Update ()
{
this.transform.position += this.transform.forward * Time.deltaTime * normbulletspd;
bulletinside = GetComponent<ObjectState>().inEffect;
//slow = GetComponent<ObjectState>().slow;
fastforward = GetComponent<ObjectState>().fast;
freeze = GetComponent<ObjectState>().stop;
if(!bulletinside)
{
this.transform.position += this.transform.forward * Time.deltaTime * normbulletspd;
}
if(bulletinside)
{
if(freeze !fastforward !slow)
{
bulletSpd=0.0f;
rigidbody.AddForce(transform.forward * bulletSpd);
}
else if(fastforward !slow !freeze)
{
bulletSpd= 2000.0f;
rigidbody.AddForce(transform.forward * bulletSpd);
}
else if(slow)
{
SlowDown();
}
else
{
bulletSpd = 100.0f;
rigidbody.AddForce(transform.forward * bulletSpd);
}
}
}
public void SlowDown()
{
Debug.Log("SlowDown");
normbulletspd = 1.0f;
}