Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- player presses space;and you have the current direction to throw the rope.
- set up ray: new Ray(player.position, direction, start_distance);
- each-frame after pressing space {
- ray.position = player.position;
- var result = space.rayCast(ray);
- if(result!=null) {
- //yay rope hit something
- create rope joint with player position, and ray.at(result.distance)
- }else {
- //still not hit anything
- ray.maxDistance += distance_increment;
- }
- }
- ------------------------------------------ SAME AS ABOVE BUT WITH GRAPHICS ----------------
- player presses space;and you have the current direction to throw the rope.
- set up ray: new Ray(player.position, direction, start_distance);
- each-frame after pressing space {
- ray.position = player.position;
- var result = space.rayCast(ray);
- if(result!=null) {
- //yay rope hit something
- create rope joint with player position, and ray.at(result.distance)
- start rendering rope as normal based on rope anchor points.
- }else {
- //still not hit anything
- ray.maxDistance += distance_increment;
- render rope from player.position up to ray.at(ray.maxDistance)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment