Hi,
The problem is when I am strafing the character left or right and I instantiate a projectile, the projectile is instantiated 'late' and does not remain in front of the player. Is there a way to update the position somehow?
I know that the multiplication assignment operation "*=" can be applied to rotations, but it cannot be applied to a transform.position, it seems like I would use something like that?
public class ScriptA : MonoBehaviour {
private bool instPrefab = false;
void Update()
{
if (Input.GetKeyDown(KeyCode.LeftControl)) {
instPrefab = true;
ScriptB.SetVelocity(5);
}
}
}
public class ScriptB : MonoBehaviour {
public GameObject prefab;
void Update()
{
if (ScriptA.instPrefab) {
//get velocity that we set
Instantiate(prefeb, transform.position, transform.rotation);
ScriptA.instPrefab = false;
}
}
}
posting your code or at least a better description of it's structure could help others to answer your question easily!
– Ashkan_gcCould you explain to me again if this is possible with the code above (edited)?
– anon99153346