For some reason, I can't get this to work. What I want is the platform to read if an object (player, ball, etc.) is OnTriggerEnter and, if so, apply transformdirection. public int force = 20; void OnTriggerEnter(Collider item) { item.transform.TransformDirection(Vector3.up * force); } (The script is applied to the platform, not the player or ball.)
You could try using Rigidbody.AddForce. I use it for normal jumping http://docs.unity3d.com/ScriptReference/Rigidbody.AddForce.html
The problem is that the object isn't responding to anything. When the object is on the jump pad, it doesn't do anything but just pass through the pad.
I sort of solved the problem, but now I have a new issue. The problem was that the trigger was not reading that the player has a collider. I am currently using the built-in Unity 5 fps controller which uses a character controller collider, but yet the trigger refuses this. How can I make the trigger read the controller as an actual collider?
Do a Debug.Log(item.name) in your TriggerEnter function. Also, as per your OP, item.transform.TransformDirection(Vector3.up * force); does not do what you intend it to do. See, http://docs.unity3d.com/ScriptReference/Transform.TransformDirection.html
There is too little information to go on. Do a debug.Log like I said, and check if the name printed out is the name of your Player gameobject.
FPSController UnityEngine.Debug:Log(Object) platform_bounce:OnTriggerEnter(Collider) (at Assets/scripts/environmental_features/platform_bounce.cs:11) (FPSController meaning the player object) Also, here is the error I get when the player collides with the platform: NullReferenceException: Object reference not set to an instance of an object platform_bounce.OnTriggerEnter (UnityEngine.Collider item) (at Assets/scripts/environmental_features/platform_bounce.cs:12)
attachedRigidbody is obviously null. Is the rigidbody component below or above the gameobject which contains your player collider within the hierarchy? Or is it on the same gameObject? Also, like I said, transform.TransformDirection (Vector3.up * force);...will do absolutely nothing.
The rigidbody is attached to the main player gameobject and is below the player collider. Also, the transformdirection statement does work as I placed a cube with a rigidbody and it caused the cube to bounce upward
http://docs.unity3d.com/ScriptReference/Collider-attachedRigidbody.html Try placing the rigidbody on the top node of the Players hierarchy. Also, my bad on that, it WILL do something, it's not how I would do it though.
the issue is that the script is not reading that the player has a collider attached, not a rigidbody. Technically, the player does have a collider, but it is a playercontroller component. How exactly do I get it to read the playercontroller component as a collider?
Technically, a charactercontroller component is qualified as a type of collider, yet the method does not recognize it.
So i fixed and updated the script for you here it is bro public class JumpPad : MonoBehaviour { public GameObject PlayerCtrl; public float AmountOfForce = 20; void OnTriggerEnter(Collider PlayerCtrl){ PlayerCtrl.transform.TransformDirection (Vector3.up * AmountOfForce); } }