Method magically changing input parameter?

I have s imply bouyancy script for floating objects. I pilfered it from somewhere, but it’s just a simple application of force at the point of bouyancy. I’m trying to apply multipl point of bouyancy, to simulate real objects. However, regardless of the offset points i put in, it alway defaults to 0,0,0. Specifically, the debug log for iteratebuoyancypoints shows the correct points, but when they are passed to applybouyancy, they’re all converted to 0,0,0.

I don’t have a clue how or why this could be happening, and I’ve played about a lot, with the code. i’m sure it’s something simple I’m missing, but can anyone see it?

using UnityEngine;
using System.Collections;

public class Floater : MonoBehaviour {
	public float waterLevel, floatHeight;
	private Vector3 buoyancyOffset;
	public Vector3[] buoyancyOffsets;
	public float bounceDamp;
	public Vector3 massCentre;
	public Rigidbody rb;
	Color color;
	

	void Start(){
		rb = GetComponent<Rigidbody>();
		rb.centerOfMass = massCentre;
	}

	void FixedUpdate () {

		IterateBuoyancyPoints (buoyancyOffsets);

	}

	public void AddBuoancyPoint(){

	}

	public void RemoveBuoancyPoint(){
	}

	private void IterateBuoyancyPoints(Vector3[] buoyancyOffsets){
		
		for(int i = 0; i < buoyancyOffsets.Length; i++){
			if(i==0){color = Color.red;} else if(i==1){color = Color.blue;}else if(i==2){color = Color.green;};
			ApplyBouancy(buoyancyOffsets*, color);*

_ Debug.Log (buoyancyOffsets*);_
_
}*_

* }*

* private void ApplyBouancy(Vector3 buoancyOffset, Color color){*
* Vector3 actionPoint = transform.position + transform.TransformDirection(buoyancyOffset);*
* float forceFactor = 1f - ((actionPoint.y - waterLevel) / floatHeight);*
* Debug.Log (buoyancyOffset);*

* if (forceFactor > 0f) {*
_ Vector3 uplift = -Physics.gravity * (forceFactor - GetComponent ().velocity.y * bounceDamp);_
* GetComponent ().AddForceAtPosition (uplift, actionPoint);*
* Debug.DrawRay (actionPoint, uplift, color, 10f);*

* }*
* }*

Check the naming of your variables/parameters.

private Vector3 buoyancyOffset;

This Vector3 is redundant. You don’t set it anywhere and you probably don’t want to use in anywhere… You do get it inside ApplyBouancy, but sinse you never set it, it is [0,0,0]

private void ApplyBouancy(Vector3 buoancyOffset, Color color)

The parameter ‘buoancyOffset’ is never used. Instead you are using ‘buoyancyOffset’

The answer is quite simple you have a misspelled parameter name. You have a public variable called “buoyancyOffset” but your methods parameter name is called “buoancyOffset”. Inside your method you use the public variable of the script and not the parameter.

I usually prefix parameter names with a lowercase “a” (for argument). That way i can’t confuse it with other variables.