Lack of accuracy while spawning an effect on a rotating sphere.
Hello,
I'm trying to spawn a particle effect from a player sphere that rotates in world space. I'm on the good way to achieve this but as we can see on the two following screenshots, it's quite inaccurate in some situations.
Case 1 : quite correct.
Case 2 : very inaccurate
As you can see, I try to pass the same rotation vector to the addforce and to the rotation component when spawning the particle effect but, as said in the title, it's really inaccurate for the spawning.
I've also another question about this addforce function. In the User Manual it is said that this function is not FPS dependant but i get very very strange behaviours on slow computers or when turning timescale to 0.1 for example that let me guess that it's more complicated than it seems. When I turn timescale to 0.1 my player travels 10 time faster than it should.
Here is my code :
// in the Update function
dir.x = Input.GetAxis ("Horizontal");
dir.z = Input.GetAxis ("Vertical");
if (dir.magnitude > 1)
dir.Normalize ();
rotatedDir = camTransform.TransformDirection(dir);
rotatedDir = new Vector3(rotatedDir.x, 0, rotatedDir.z);
rotatedDir = rotatedDir.normalized * dir.magnitude;
controller.AddForce (rotatedDir * moveSpeed);
if (Input.GetKeyDown("space"))
{
Boost(boostSpeed);
}
public void Boost (float boost)
{
if (lightJump != null)
{
Vector3 spawnPoint = playerTransform.position;
Quaternion spawnRotation = Quaternion.LookRotation(rotatedDir);
lightJump = Instantiate (lightJump, spawnPoint, spawnRotation) as ParticleSystem;
}
controller.AddForce (controller.velocity.normalized * boost, ForceMode.VelocityChange);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612114740im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Applying AddForce() while rotating player gameobject. 0 Answers
Rotat a GameObject and than shoot it in the New (x) direction 1 Answer
How do i find player rotation and convert that into a force facing that direction. 0 Answers
Getting 2D Turrets to rotate toward bullet direction. 1 Answer
Why does my rigidbody move it's transform while rotating? 1 Answer