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.
![alt text][1]
Case 2 : very inaccurate
![alt text][2]
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);
}
}
[1]: /storage/temp/91395-1.png
[2]: /storage/temp/91396-2.png
↧