help declaring Transform in Find statement BCE0019

I am doing the 3D Buzz TPC tutorial , and have sucessfully converted all the script to .js up until now. I am at the part of matching the ragdoll rotation to the character rotation.

So, I need help understanding and converting this specific part of code :-

This is the line in C# →

void MatchChildrenTransforms(Transform source, Transform target)
	{
		foreach(Transform sourceTransform in source.transform)
			{
				Transform targetTransform = target.Find(sourceTransform.name);

This is my line in JS →

function MatchChildrenTransforms(source : Transform, target : Transform) : void
	{
		for(var sourceTransform in source.transform)
			{
				var targetTransform = target.Find(sourceTransform.name);
  • this gives the error → Assets/SCRIPTS_ JS/Script_ TP_ Animator.js(564,83): BCE0019: ‘name’ is not a member of ‘Object’.

I have also tried all of the following combinations :

var targetTransform = target.Find(sourceTransform.name) as Transform;

var targetTransform = target.Find(sourceTransform.transform.name);

var targetTransform = target.Find(transform.sourceTransform.name);

var targetTransform = target.transform.Find(sourceTransform.name);

and even all the combinations with gameObject instead of transform.

the Unity Scripting Reference only shows a string search in → transform.Find(“E.G.”);

I feel I have to declare a typecast of Transform somewhere , but this one is eluding me. Any help would be greatly appreciated (I’m 4 video’s away from completing Section 4 and the full TPC!)

Link to tutorial : http://www.3dbuzz.com/vbforum/content.php?212 (Section 4 , Part 31)

Working JS conversion up to climbing (just for a laugh): http://www.alucardj.net16.net/examples/TPC-tutorial/TPCterrainworld.html

(and I am a little annoyed at myself for getting this far with searches, except for learning Singleton, then being stuck here on recursion). Thanks , Jay.

Hey mate,

sourceTransform is being dynamically typecast as an Object I believe. You need to declare sourceTransform as a Transform to access child components of source.transform like so:

for(var sourceTransform : Transform in source.transform)

I believe that should work. :slight_smile:

Hope that helps, Klep

P.S. By the way man! I’m a mod! Woohoo! :stuck_out_tongue: