Hi there,
I have a quick problem with the syntax of using OnTriggerEnter where i want a falling cube to hit a paddle and bounce back up like on a trampoline. I realise this is one of the most obvious of unity questions but I have scoured the internet and simply cant find an example of the javascript i require. (I have used a Collider instead of trigger but because I’m using a cube it would hit the paddle and fall to one side and then go crazy, I’m looking for a smooth almost stylised bounce (not sending it flying with crazy rotations) regardless of the shape of the collider.
I’m using variations of the following…
var bounceSpeed : float = 8; function OnTriggerEnter(thing: Collider){ if (thing.tag == "trampoline"){ cube.rigidbody.AddForce(bounceSpeed * Vector3.up, ForceMode.Force); } }
and nothing is working.
I am attaching that script to the ‘cube’ and making the cube a trigger.
I know this has been posted many times but every example im trying to change for my own use is failing. Any help would be great.
Thanks in advance.