using UnityEngine;
using System.Collections;
Looks good to me. What do you think you’re doing wrong?
EDIT:
Actually, wait, do you need to add != null to that null check?
Well, what’s the problem? Help people help you.
There’s not enough information given to know if your collisions are set up properly. It may not be doing anything because it’s not registering the collision at all. Is the SloMo script on an object with a trigger collider (trigger set to true)? Is your collision matrix set to allow collisions between the layer on the SloMo object and on the character controller object?
You should use the debugger or at least Debug.Log to figure out what’s going on. Put a print inside of the on trigger enter to see if it’s being called or not. If not, then you know your problem is with how you set your collisions up. If so, see if it’s finding the component. Is it returning null? Put an else statement with a Debug.Log and see if that’s running.
That sort of information can help narrow down the problem.
Ah, yes. Your script defines a class inside of the class and makes an instance of it within. You have to access the component and then access the instance of the CharacterMotorMovement class defined inside.
I suppose you would want to say
GetComponent<CharacterMotorC>().movement.maxForwardSpeed = 2.0f;
What’s on line 11? Doesn’t seem to match your post. Is the component (from the other collider) null? Null for a component means it’s not attached to the game object.
One thing you’re doing is you’re checking to see if the object that entered the trigger has the character motor, and if so, you’re changing the character motor of the object that has the SloMo script.
Perhaps you meant to say;
other.GetComponent<…>()…
after the if condition.
You had that in your first post but removed it, possibly since I didn’t include it in my example (I wasn’t putting the complete code).
Glad you figured it out :).
I don’t think there’s an official way to mark it solved, other than putting [Solved] in the title. That should be good enough.