Set variable to position of collided object.
Trying to make a game with a friend and I've hit a snag. I wrote a script that on colliding with an object with the tag "platform" should set one variable to the player's y coordinate, another to the Vector3 of the collided object and another to the y coordinate of the collided object.
I've tried multiple bits of code and changed it several times but nothing seems to work. The script is
 using UnityEngine;
 using System.Collections;
 
 public class drop_script : MonoBehaviour {
     public int fall_distance;
     public GameObject player;
     GameObject block;
     Vector3 previous_pos;
     float player_y;
     float block_y;
 
     void OnCollisionEnter(Collision col) {
         player_y = player.transform.position.y;
         block = col.gameObject;
         block_y = block.transform.position.y;
         previous_pos = block.transform.position;
     }
     // Update is called once per frame
     void Update () {
         if (player_y <= (block_y - fall_distance)) {
             player.transform.position.Set(previous_pos.x, previous_pos.y + 2, previous_pos.z);
         }
     }
 }
 
Here's the project files as well. https://www.dropbox.com/s/a3k26lnrgg8zqh1/dropper.zip?dl=0
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
How to Make A Character Stop At Wall? 0 Answers
How to move Raycast Hit Object 0 Answers
Toggle collider with key 0 Answers
Need help with making a burger mechanic. 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                