|
In my game, the player can jump through hoops which adds to the player's current velocity. On contact, each hoop passes a Vector3 to the player script, however, if I tilt the hoop to create angled jumps, the Vector3 passed does not change, so the player is thrown in world space. Is there any way to change the Vector3 passed from the hoop depending on its angle so that the angle affects the direction of the jump? Thanks! Here's the hoop script.
(comments are locked)
|
|
I suggest you to change the idea a little: define a float speed in the hoop script, then pass the velocity vector as transform.up multiplied by this speed. It makes things a lot easier, since you know that the speed may have different intensities, but will always point the up side of each hoop - just tilt each hoop to the orientation you want:
var velocityToAdd: float = 10;
...
function OnTriggerEnter (myTrigger : Collider) {
if(myTrigger.gameObject.name == "Player"){
gameScript.addVelocity(transform.up * velocityToAdd);
Destroy(gameObject);
}
}
Thats perfect, much simpler, thanks!
Oct 05 '11 at 08:59 PM
ataxk
(comments are locked)
|
