Is it possible to extend my Class form the Transform class

Hi.

Is it possible to extend a Class form the Transform class?
like

public class myWheel : Transform
{
    public myWheel() { }
}

thanx in advance

I don’t think it is. And even if it were, how would you go about replacing the existing transform of a GameObject by your own implementation?

Why do you want to inherit from Transform? I don’t really see why that would be useful.

Well… I have made a truck wich is one solid mesh with all wheels attached. These wheels are transformable by bones.

Therefore i’ve made a Truck controler script.
In this script i’ve made 4 public Transform properties for the wheels. So i can attach each wheel to the apropriate Transform. What i want to do is that each wheels rotation is calculated by its displacement.
so i thought, if i can extend from Transform. i can create 1 script for all wheels. so they can rotate independetly.

en btw ik zie dat je uit Nederland komt. Wat leuk…
En nog werkt in Utrecht ook…

With unity, you would typically just make each wheel a child of your truck/chassis object and ensure that each wheel has the same script component to control it’s behavior.

The wheel offset and rotation is then maintained in relation to the main object.

I was looking for this as well. I wanted to inherit Transform and limit access to some things, like making Transform.position a property with private setter access, etc.

I guess I’ll just have to roll my own wrapper.

EDIT: Actually a wrapper won’t work because I can’t substitute it where the expect type is Transform =(

You’d actually want to extend both GameObject and Transform in order to do the implementation correctly. That being said - I would lean towards using the framework as intended and making those objects children of the overall Truck parent.

1 Like

@KelsoMRK Hi, I beat a dead thread to extend the discussion of extending Transform. I didn’t mean to cause replies to the OP from 2009. Sorry for not being clear. The goal in my case is to limit public write access to some members.

Oops - my fault. I should have looked at the post dates. :slight_smile: