Error: Cannot modify a value type return value. Consider storing the value in a temporary variable.

    void OnCollisionEnter (Collision col)
    {
        foreach (ContactPoint contact in col.contacts)
        {
            if (contact.thisCollider == collider)
            {
                // This is the paddle contact point
                float english = contact.point.x = transform.position.x;       
                contact.otherCollider.rigidbody.AddForce(300f * english, 0, 0);
            }
        }
    }
}

Error: Cannot modify a value type return value of 'UnityEngine.ContactPoint.point. Consider storing the value in a temporary variable.

Help?

It looks like you're trying to do two assignments on line 8. What the error is telling you is that the second one cannot be performed (contact.point.x = transform.position.x).

What are you trying to do here?

Vector3 contactPoint = contact.point;
contactPoint.x = transform.position.x;
contact.point = contactPoint;

Two assignments is not the problem. Its not common practice, but its totally legal.

The problem is Vector3 is a struct. When you access a struct the data is copied to the new location. So this line does absolutely nothing.

transform.position.x = 4;

The way to solve it is to use a temporary variable, as indicated by the error message.

Vector3 temp = transform.position;
temp.x =4;
transform.postition = temp;

Your suggestions are great but I am unsure how to implement them (hence why this post is in Getting Started)? Do I initialize the temporary variable before my update code?

Ive tried to implement it like this:

    void OnCollisionEnter (Collision col)
    {       
        foreach (ContactPoint contact in col.contacts)
        {
            if (contact.thisCollider == collider)
            {
                Vector3 ContactPoint = contact.point;
                ContactPoint.x = transform.position.x;
                contact.point = ContactPoint;

                float english = contact.point.x = transform.position.x;       
                contact.otherCollider.rigidbody.AddForce(300f * english, 0, 0);
            }
        }
    }
}

But got the following error: Property or indexer 'UnityEngine.ContactPoint.point' cannot be assigned to (it is a read only)

You've got a weird mix up of code here. I can't make any sense of the logic. What are you actually trying to do?

A plain English description will help to figure out what you need.

I am trying to make a paddle which affects in which direction the ball it is interacting with shoots off. Hitting the middle makes the ball go up, hitting the left side makes the ball shoot off to the left, right side shoots off to the right. I am trying to achieve this by following Quill's Block Breaker tutorial but line for line the code isn't working:

https://www.youtube.com/watch?v=ZBTI_0t_Jas

I found the bug. I had a = instead of a -

float english = contact.point.x = transform.position.x;