x


Transform.position issue

Hi there, Quick question. Probably another small one that I will facepalm about later,

 using UnityEngine;
    using System.Collections;

    public class Cover : MonoBehaviour {

        public Transform Player;
        void OnTriggerStay (Collider other)
        {
           if(Input.GetButtonDown("Cover")){
             Movement.inCover = true; 
             Player.position = new Vector3 (Player.position, 1, Player.position);
           }

           if (Input.GetButtonUp("Cover")){
             Movement.inCover = false;
           }
        }
    }

I am getting the error regarding issues with Vector3 float, float, float. I know it is something to do with me using Player.position but I want to keep the Player position for the x and z axis and only change the y axis position. Do I have to define where it is, I though thats what transform was for :/

Cheers,

more ▼

asked Dec 15 '11 at 11:42 PM

doomprodigy gravatar image

doomprodigy
557 22 27 31

(comment moved to answer board)

Dec 15 '11 at 11:51 PM Lo0NuhtiK

Face palming imminent, well spotted lo0Nuhtik! @Aaron not making fun, just glad to see I'm not the only one... @Loo when you have an answer, post it as such: you want the points, I saw...

Dec 15 '11 at 11:55 PM gregzo

Ah face palm indeed imminent. Put that in an answer so this is not left unanswered and cluttering up UA.

Dec 15 '11 at 11:58 PM doomprodigy
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Player.position = new Vector3(Player.position, 1, Player.position) returns a Vector3(Vector3,1,Vector3)...
try Vector3(Player.position.x , 1 , Player.position.z)

more ▼

answered Dec 16 '11 at 01:32 AM

Lo0NuhtiK gravatar image

Lo0NuhtiK
3.5k 1 10 39

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x117
x1

asked: Dec 15 '11 at 11:42 PM

Seen: 685 times

Last Updated: Dec 16 '11 at 01:47 AM