adding forces and ray casts at children's position/rotation

hi
I’ve been playing with trying to setup some more complicated vehicle systems (hovering vehicle) by adding forces to engines, I’m a game artist and this is possibly my second week of dabbling in coding so excuse the horrible “artist code”

i have this simple code that ray casts downwards (relatively) and then produces a force in the opposite direction if within a certain tolerance:

RaycastHit hit;
		Debug.DrawRay(transform.position, -transform.up * hoverHeight);

		if (Physics.Raycast (transform.position, -transform.up,out hit,hoverHeight))
		{
		float height = hit.distance;
		float actualForce = hoverHeight - height;
			if (actualForce < 0f)
				actualForce = 0f;

			rigidbody.AddRelativeForce(transform.up * (actualForce * hoverForce));


			Debug.DrawRay(transform.position, transform.up * actualForce ,Color.red);

		}

this works fine on a single engine it does exactly what i want it to, now i can’t seem to make this part of a more complex system easily

obviously first issue is i can’t add forces to child rigid bodies without lots of issues, tried adding fixed joints but everything gets very spongy and goes very wrong, so I’m trying to apply offset forces to the parent object using its children’s offset transforms.

problem is this goes beyond my knowledge it seems
I’ve added four public transforms which i hoped i could use as replacements for the transform.postions and transform.up but i can’t…

i want to use the colds transform offset from the parent to cast a ray from and then produce a force for multiple engines so that the vehicle balances on these

any ideas of the best way to do this, I’ve looked for hours now and can’t find a solution, now I’m sure I’ve just missed something simple but if you could point me in the direction i would be very grateful

cheers

fixed this one myself…

	[SerializeField]
	public GameObject hoverEngineL;
	[SerializeField]
	public GameObject hoverEngineR;
	[SerializeField]
	public GameObject hoverEngineF;
	[SerializeField]
	public GameObject hoverEngineB;

	// Update is called once per frame
	void FixedUpdate () 
	{
				//hoverengine LEFT
				RaycastHit hitL;
				//draw debug ray for hover test
				Debug.DrawRay (hoverEngineL.transform.position, - hoverEngineL.transform.up * hoverHeight);
				//test for object to push against
				if (Physics.Raycast (hoverEngineL.transform.position, -transform.up, out hitL, hoverHeight)) 
				{
				//add tolerence and dampening
				float height = hitL.distance;
				float actualForce = hoverHeight - height;
				if (actualForce < 0f)
				actualForce = 0f;
				//add force at 
				rigidbody.AddForceAtPosition(hoverEngineL.transform.up * (actualForce * hoverForce), hoverEngineL.transform.position);
				//draw debug ray for force
				Debug.DrawRay (hoverEngineL.transform.position, hoverEngineL.transform.up * actualForce, Color.red);

				}

the mismatch seemed to sort itself out so I’m guessing it didn’t compile properly before…
anyway now i have a floaty vehicle that bounces around on four “hover engines”