- Home /
overlapshere wont convert its hit colliders name to a string
My player info variable(Which is a string) is always blank no matter what why? yet it's hitting something and if I debug log _hitcollider[i].name it gives me the name of the collider\
public void hitPlayerCalcSplash(RaycastHit _hitInfo)
{
//if (hitPlayer == true) {
//Debug.Log(_hitInfo.collider.name);
_hitColliders = Physics.OverlapSphere(_hitInfo.point, splashRadius);
for (int i = 0; i < _hitColliders.Length; i++)
{
if (_hitColliders[i].tag == "Player")
{
proximity = (_hitInfo.point - _hitInfo.collider.transform.position).magnitude;
Splashdamage = CritHitDamage - (proximity / splashRadius);
_hitColliders[i].name = playerInfo;
Debug.Log(playerInfo);
}
}
what is playerInfo? is it a string? can't see it in your script here
Oh sorry yes player info is a string my bad
Answer by Priyanka-Rajwanshi · Apr 07, 2018 at 08:16 PM
_hitColliders[i].name = playerInfo; //wrong assignment
In this line you are not assigning value to playerInfo but to the collider. As per your question, this should be
playerInfo = _hitColliders[i].name;
Answer by Cornelis-de-Jager · Apr 05, 2018 at 06:19 AM
Instead of using collider, use gameobject.
So in your instance:
_hitColliders[i].gameObject.name = playerInfo;
Any idea why this shouldn't work like this doesn't make sense
Your answer
Follow this Question
Related Questions
For loop on text without effecting each other 1 Answer
cant get if (String.Equals(magicsetom[x], boxadd)) working 0 Answers
Comparing two Strings. Returns equal and not equal at the same time? 3 Answers
if statement not returning true 1 Answer
Check if specific object exist in list or array, Best Practices? 2 Answers