Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

error CS0029: Cannot implicitly convert type `float' to `UnityEngine.Vector3'

$
0
0
using System.Collections; using System.Collections.Generic; using UnityEngine; public class grabobjects : MonoBehaviour { public float pickUpRange = 5; public float moveForce = 250; private GameObject heldobject; public Transform holdParent; // Update is called once per frame void Update () { if (Input.GetKey(KeyCode.E)){ if (heldobject != null){ RaycastHit hit; if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, pickUpRange)){ PickupObject (hit.transform.gameObject); } } else { DropObject(); } } if (heldobject != null) { moveObject(); } } void moveObject () { if (Vector3.Distance(heldobject.transform.position, holdParent.position =+ 0.1f)){ Vector3 moveDirection = (holdParent.position = heldobject.transform.position); heldobject.GetComponent() .AddForce(moveDirection * moveForce); } } void PickupObject (GameObject pickobj) { if (pickobj.GetComponent()) { Rigidbody objRig = pickobj.GetComponent(); objRig.useGravity = false; objRig.drag = 10f; objRig.transform.parent = holdParent; heldobject = pickobj; }} void DropObject() { Rigidbody heldrig = heldobject.GetComponent(); heldrig.useGravity = true; heldrig.drag = 1f; heldobject.transform.parent = null; heldobject = null; } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>